From 7717a97466673d0f580e9a5f8ab3a3b7f7d0456e Mon Sep 17 00:00:00 2001 From: Dmitri Babaev Date: Wed, 27 Apr 2011 19:31:55 +0400 Subject: [PATCH 001/264] keys for live tests are loaded from the classpath --- .../openstack/nova/live/PropertyHelper.java | 16 ++++++++-------- .../resources/keys/{rhelimpg.pub => rhelimg.pub} | 0 2 files changed, 8 insertions(+), 8 deletions(-) rename sandbox-apis/nova/src/test/resources/keys/{rhelimpg.pub => rhelimg.pub} (100%) diff --git a/sandbox-apis/nova/src/test/java/org/jclouds/openstack/nova/live/PropertyHelper.java b/sandbox-apis/nova/src/test/java/org/jclouds/openstack/nova/live/PropertyHelper.java index 73def076ee..3f65a987e9 100644 --- a/sandbox-apis/nova/src/test/java/org/jclouds/openstack/nova/live/PropertyHelper.java +++ b/sandbox-apis/nova/src/test/java/org/jclouds/openstack/nova/live/PropertyHelper.java @@ -18,18 +18,18 @@ */ package org.jclouds.openstack.nova.live; -import com.google.common.base.Charsets; -import com.google.common.collect.ImmutableMap; -import com.google.common.io.Files; -import org.jclouds.Constants; - -import java.io.File; import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; import java.util.Map; import java.util.Properties; +import org.jclouds.Constants; + +import com.google.common.base.Charsets; +import com.google.common.collect.ImmutableMap; +import com.google.common.io.Resources; + /** * @author Victor Galkin */ @@ -44,8 +44,8 @@ public class PropertyHelper { public static Map setupKeyPair(Properties properties) throws FileNotFoundException, IOException { return ImmutableMap.of( - "private", Files.toString(new File(properties.getProperty("test.ssh.keyfile.private")), Charsets.UTF_8), - "public", Files.toString(new File(properties.getProperty("test.ssh.keyfile.public")), Charsets.UTF_8)); + "private", Resources.toString(Resources.getResource(properties.getProperty("test.ssh.keyfile.private")), Charsets.UTF_8), + "public", Resources.toString(Resources.getResource(properties.getProperty("test.ssh.keyfile.public")), Charsets.UTF_8)); } public static Properties setupProperties(Class clazz) throws IOException { diff --git a/sandbox-apis/nova/src/test/resources/keys/rhelimpg.pub b/sandbox-apis/nova/src/test/resources/keys/rhelimg.pub similarity index 100% rename from sandbox-apis/nova/src/test/resources/keys/rhelimpg.pub rename to sandbox-apis/nova/src/test/resources/keys/rhelimg.pub From 8d7609964b9cf51422883ae27ce6fe29e6954eb2 Mon Sep 17 00:00:00 2001 From: Dmitri Babaev Date: Fri, 27 May 2011 17:44:24 +0400 Subject: [PATCH 002/264] additional json test --- ...ServerFromJsonNoAddressesResponseTest.java | 75 ++++++++ .../ParseServerFromJsonResponseTest.java | 160 +++++++++--------- .../test_get_server_detail_no_addresses.json | 20 +++ 3 files changed, 175 insertions(+), 80 deletions(-) create mode 100644 sandbox-apis/nova/src/test/java/org/jclouds/openstack/nova/functions/ParseServerFromJsonNoAddressesResponseTest.java create mode 100644 sandbox-apis/nova/src/test/resources/test_get_server_detail_no_addresses.json diff --git a/sandbox-apis/nova/src/test/java/org/jclouds/openstack/nova/functions/ParseServerFromJsonNoAddressesResponseTest.java b/sandbox-apis/nova/src/test/java/org/jclouds/openstack/nova/functions/ParseServerFromJsonNoAddressesResponseTest.java new file mode 100644 index 0000000000..9aef753f4e --- /dev/null +++ b/sandbox-apis/nova/src/test/java/org/jclouds/openstack/nova/functions/ParseServerFromJsonNoAddressesResponseTest.java @@ -0,0 +1,75 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.jclouds.openstack.nova.functions; + +import com.google.inject.Guice; +import com.google.inject.Injector; +import com.google.inject.Key; +import com.google.inject.TypeLiteral; +import org.jclouds.http.HttpResponse; +import org.jclouds.http.functions.UnwrapOnlyJsonValue; +import org.jclouds.io.Payloads; +import org.jclouds.json.config.GsonModule; +import org.jclouds.openstack.nova.domain.Server; +import org.jclouds.openstack.nova.domain.ServerStatus; +import org.testng.annotations.Test; + +import java.io.InputStream; +import java.net.UnknownHostException; +import java.text.ParseException; + +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertTrue; + +@Test(groups = "unit") +public class ParseServerFromJsonNoAddressesResponseTest { + + @Test + public void testApplyInputStreamDetails() throws UnknownHostException, NoSuchMethodException, ClassNotFoundException, ParseException { + Server response = parseServer(); + + assertEquals(response.getId(), 847); + assertEquals(response.getName(), "cmsNode-fa2"); + assertEquals(response.getImageRef(), "http://dragon004.hw.griddynamics.net:8774/v1.1/images/106"); + assertEquals(response.getFlavorRef(), "http://dragon004.hw.griddynamics.net:8774/v1.1/flavors/2"); + assertEquals(response.getStatus(), ServerStatus.BUILD); + + assertTrue(response.getAddresses().getPublicAddresses().isEmpty()); + assertTrue(response.getAddresses().getPrivateAddresses().isEmpty()); + } + + public static Server parseServer() throws NoSuchMethodException, ClassNotFoundException { + + Injector i = Guice.createInjector(new GsonModule() { + @Override + protected void configure() { + super.configure(); + bind(DateAdapter.class).to(Iso8601DateAdapter.class); + } + }); + + InputStream is = ParseServerFromJsonNoAddressesResponseTest.class.getResourceAsStream("/test_get_server_detail_no_addresses.json"); + + UnwrapOnlyJsonValue parser = i.getInstance(Key.get(new TypeLiteral>() { + })); + + return parser.apply(new HttpResponse(200, "ok", Payloads.newInputStreamPayload(is))); + } + +} diff --git a/sandbox-apis/nova/src/test/java/org/jclouds/openstack/nova/functions/ParseServerFromJsonResponseTest.java b/sandbox-apis/nova/src/test/java/org/jclouds/openstack/nova/functions/ParseServerFromJsonResponseTest.java index 25c7a1aac8..22f33a2801 100644 --- a/sandbox-apis/nova/src/test/java/org/jclouds/openstack/nova/functions/ParseServerFromJsonResponseTest.java +++ b/sandbox-apis/nova/src/test/java/org/jclouds/openstack/nova/functions/ParseServerFromJsonResponseTest.java @@ -1,23 +1,23 @@ -/** - * - * Copyright (C) 2011 Cloud Conscious, LLC. - * - * ==================================================================== - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ==================================================================== - */ -package org.jclouds.openstack.nova.functions; - +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.jclouds.openstack.nova.functions; + import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.common.collect.Iterables; @@ -45,63 +45,63 @@ import java.util.Locale; import java.util.SimpleTimeZone; import static org.testng.Assert.assertEquals; - -/** - * Tests behavior of {@code ParseServerFromJsonResponse} - * - * @author Adrian Cole - */ -@Test(groups = "unit") -public class ParseServerFromJsonResponseTest { - - @Test - public void testApplyInputStreamDetails() throws UnknownHostException, NoSuchMethodException, ClassNotFoundException, ParseException { - Server response = parseServer(); - - assertEquals(response.getId(), 1234); - assertEquals(response.getName(), "sample-server"); - assertEquals(response.getImageRef(), "https://servers.api.rackspacecloud.com/v1.1/1234/images/1"); - assertEquals(response.getFlavorRef(), "http://servers.api.openstack.org/1234/flavors/1"); - assertEquals(response.getHostId(), "e4d909c290d0fb1ca068ffaddf22cbd0"); - assertEquals(response.getStatus(), ServerStatus.BUILD); - assertEquals(response.getProgress(), new Integer(60)); - SimpleDateFormat dateFormat = new SimpleDateFormat( - "yyyy-MM-dd'T'HH:mm:ss'Z'", Locale.US); - dateFormat.setTimeZone(new SimpleTimeZone(0, "GMT")); - assertEquals(response.getCreated(), - dateFormat.parse("2010-08-10T12:00:00Z")); - assertEquals(response.getUpdated(), - dateFormat.parse("2010-10-10T12:00:00Z")); - - List
publicAddresses = ImmutableList.copyOf(Iterables.transform( - ImmutableList.of("67.23.10.132", "::babe:67.23.10.132", "67.23.10.131", "::babe:4317:0A83"), - Address.newString2AddressFunction())); - List
privateAddresses = ImmutableList.copyOf(Iterables.transform( - ImmutableList.of("10.176.42.16", "::babe:10.176.42.16"), - Address.newString2AddressFunction())); - Addresses addresses1 = new Addresses(new HashSet
(publicAddresses), new HashSet
(privateAddresses)); - assertEquals(response.getAddresses(), addresses1); - assertEquals(response.getMetadata(), ImmutableMap.of("Server Label", "Web Head 1", "Image Version", "2.1")); - assertEquals(response.getAddresses(), addresses1); - } - - - public static Server parseServer() throws NoSuchMethodException, ClassNotFoundException { - - Injector i = Guice.createInjector(new GsonModule() { - @Override - protected void configure() { - super.configure(); - bind(DateAdapter.class).to(Iso8601DateAdapter.class); - } - }); - - InputStream is = ParseServerFromJsonResponseTest.class.getResourceAsStream("/test_get_server_detail.json"); - - UnwrapOnlyJsonValue parser = i.getInstance(Key.get(new TypeLiteral>() { - })); - - return (Server) parser.apply(new HttpResponse(200, "ok", Payloads.newInputStreamPayload(is))); - } - -} + +/** + * Tests behavior of {@code ParseServerFromJsonResponse} + * + * @author Adrian Cole + */ +@Test(groups = "unit") +public class ParseServerFromJsonResponseTest { + + @Test + public void testApplyInputStreamDetails() throws UnknownHostException, NoSuchMethodException, ClassNotFoundException, ParseException { + Server response = parseServer(); + + assertEquals(response.getId(), 1234); + assertEquals(response.getName(), "sample-server"); + assertEquals(response.getImageRef(), "https://servers.api.rackspacecloud.com/v1.1/1234/images/1"); + assertEquals(response.getFlavorRef(), "http://servers.api.openstack.org/1234/flavors/1"); + assertEquals(response.getHostId(), "e4d909c290d0fb1ca068ffaddf22cbd0"); + assertEquals(response.getStatus(), ServerStatus.BUILD); + assertEquals(response.getProgress(), new Integer(60)); + SimpleDateFormat dateFormat = new SimpleDateFormat( + "yyyy-MM-dd'T'HH:mm:ss'Z'", Locale.US); + dateFormat.setTimeZone(new SimpleTimeZone(0, "GMT")); + assertEquals(response.getCreated(), + dateFormat.parse("2010-08-10T12:00:00Z")); + assertEquals(response.getUpdated(), + dateFormat.parse("2010-10-10T12:00:00Z")); + + List
publicAddresses = ImmutableList.copyOf(Iterables.transform( + ImmutableList.of("67.23.10.132", "::babe:67.23.10.132", "67.23.10.131", "::babe:4317:0A83"), + Address.newString2AddressFunction())); + List
privateAddresses = ImmutableList.copyOf(Iterables.transform( + ImmutableList.of("10.176.42.16", "::babe:10.176.42.16"), + Address.newString2AddressFunction())); + Addresses addresses1 = new Addresses(new HashSet
(publicAddresses), new HashSet
(privateAddresses)); + assertEquals(response.getAddresses(), addresses1); + assertEquals(response.getMetadata(), ImmutableMap.of("Server Label", "Web Head 1", "Image Version", "2.1")); + assertEquals(response.getAddresses(), addresses1); + } + + + public static Server parseServer() throws NoSuchMethodException, ClassNotFoundException { + + Injector i = Guice.createInjector(new GsonModule() { + @Override + protected void configure() { + super.configure(); + bind(DateAdapter.class).to(Iso8601DateAdapter.class); + } + }); + + InputStream is = ParseServerFromJsonResponseTest.class.getResourceAsStream("/test_get_server_detail.json"); + + UnwrapOnlyJsonValue parser = i.getInstance(Key.get(new TypeLiteral>() { + })); + + return parser.apply(new HttpResponse(200, "ok", Payloads.newInputStreamPayload(is))); + } + +} diff --git a/sandbox-apis/nova/src/test/resources/test_get_server_detail_no_addresses.json b/sandbox-apis/nova/src/test/resources/test_get_server_detail_no_addresses.json new file mode 100644 index 0000000000..7fdab771b1 --- /dev/null +++ b/sandbox-apis/nova/src/test/resources/test_get_server_detail_no_addresses.json @@ -0,0 +1,20 @@ +{ + "server" : { + "status":"BUILD", + "hostId":"", + "addresses": { + "public":[], + "private":[] + }, + "imageRef":"http://dragon004.hw.griddynamics.net:8774/v1.1/images/106", + "adminPass":"MHfyHXPoj88on737", + "flavorRef":"http://dragon004.hw.griddynamics.net:8774/v1.1/flavors/2", + "links" : [ + {"href":"http://dragon004.hw.griddynamics.net:8774/v1.1/servers/847","rel":"self"}, + {"href":"http://dragon004.hw.griddynamics.net:8774/v1.1/servers/847","type":"application/json","rel":"bookmark"}, + {"href":"http://dragon004.hw.griddynamics.net:8774/v1.1/servers/847","type":"application/xml","rel":"bookmark"}], + "name" : "cmsNode-fa2", + "id":847, + "metadata" : {} + } +} \ No newline at end of file From c009a8980377e8dc5beb0ff6632faa9483c18aec Mon Sep 17 00:00:00 2001 From: Dmitri Babaev Date: Fri, 27 May 2011 23:35:22 +0400 Subject: [PATCH 003/264] additional json test is moved to apis/nova --- .../functions/ParseServerFromJsonNoAddressesResponseTest.java | 0 .../src/test/resources/test_get_server_detail_no_addresses.json | 0 sandbox-apis/nova/src/test/resources/keys/rhelimg.pub | 0 3 files changed, 0 insertions(+), 0 deletions(-) rename {sandbox-apis => apis}/nova/src/test/java/org/jclouds/openstack/nova/functions/ParseServerFromJsonNoAddressesResponseTest.java (100%) rename {sandbox-apis => apis}/nova/src/test/resources/test_get_server_detail_no_addresses.json (100%) delete mode 100644 sandbox-apis/nova/src/test/resources/keys/rhelimg.pub diff --git a/sandbox-apis/nova/src/test/java/org/jclouds/openstack/nova/functions/ParseServerFromJsonNoAddressesResponseTest.java b/apis/nova/src/test/java/org/jclouds/openstack/nova/functions/ParseServerFromJsonNoAddressesResponseTest.java similarity index 100% rename from sandbox-apis/nova/src/test/java/org/jclouds/openstack/nova/functions/ParseServerFromJsonNoAddressesResponseTest.java rename to apis/nova/src/test/java/org/jclouds/openstack/nova/functions/ParseServerFromJsonNoAddressesResponseTest.java diff --git a/sandbox-apis/nova/src/test/resources/test_get_server_detail_no_addresses.json b/apis/nova/src/test/resources/test_get_server_detail_no_addresses.json similarity index 100% rename from sandbox-apis/nova/src/test/resources/test_get_server_detail_no_addresses.json rename to apis/nova/src/test/resources/test_get_server_detail_no_addresses.json diff --git a/sandbox-apis/nova/src/test/resources/keys/rhelimg.pub b/sandbox-apis/nova/src/test/resources/keys/rhelimg.pub deleted file mode 100644 index e69de29bb2..0000000000 From ebf35275952200f4e42a6804668baa511a8fddf2 Mon Sep 17 00:00:00 2001 From: Dmitri Babaev Date: Wed, 1 Jun 2011 22:17:59 +0400 Subject: [PATCH 004/264] key file for live tests is renamed --- apis/nova/src/test/resources/keys/{rhelimpg.pub => rhelimg.pub} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename apis/nova/src/test/resources/keys/{rhelimpg.pub => rhelimg.pub} (100%) diff --git a/apis/nova/src/test/resources/keys/rhelimpg.pub b/apis/nova/src/test/resources/keys/rhelimg.pub similarity index 100% rename from apis/nova/src/test/resources/keys/rhelimpg.pub rename to apis/nova/src/test/resources/keys/rhelimg.pub From 6dc6d3581fa845f022f75f32e401d58e2fa78bbd Mon Sep 17 00:00:00 2001 From: Dmitri Babaev Date: Wed, 1 Jun 2011 22:26:08 +0400 Subject: [PATCH 005/264] JschSshClinet bug fix for exec method --- .../org/jclouds/ssh/jsch/JschSshClient.java | 631 +++++++++--------- 1 file changed, 324 insertions(+), 307 deletions(-) diff --git a/drivers/jsch/src/main/java/org/jclouds/ssh/jsch/JschSshClient.java b/drivers/jsch/src/main/java/org/jclouds/ssh/jsch/JschSshClient.java index 4dea7af4e2..9e0d01244e 100644 --- a/drivers/jsch/src/main/java/org/jclouds/ssh/jsch/JschSshClient.java +++ b/drivers/jsch/src/main/java/org/jclouds/ssh/jsch/JschSshClient.java @@ -1,307 +1,324 @@ -/** - * - * Copyright (C) 2011 Cloud Conscious, LLC. - * - * ==================================================================== - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ==================================================================== - */ -package org.jclouds.ssh.jsch; - -import static com.google.common.base.Preconditions.checkArgument; -import static com.google.common.base.Preconditions.checkNotNull; -import static com.google.common.base.Preconditions.checkState; -import static com.google.common.base.Predicates.instanceOf; -import static com.google.common.base.Predicates.or; -import static com.google.common.base.Throwables.getCausalChain; -import static com.google.common.base.Throwables.getRootCause; -import static com.google.common.collect.Iterables.any; - -import java.io.IOException; -import java.io.InputStream; -import java.net.ConnectException; -import java.util.Arrays; - -import javax.annotation.PostConstruct; -import javax.annotation.PreDestroy; -import javax.annotation.Resource; -import javax.inject.Named; - -import org.apache.commons.io.input.ProxyInputStream; -import org.apache.commons.io.output.ByteArrayOutputStream; -import org.jclouds.compute.domain.ExecResponse; -import org.jclouds.http.handlers.BackoffLimitedRetryHandler; -import org.jclouds.io.Payload; -import org.jclouds.io.Payloads; -import org.jclouds.logging.Logger; -import org.jclouds.net.IPSocket; -import org.jclouds.ssh.SshClient; -import org.jclouds.ssh.SshException; -import org.jclouds.util.Strings2; - -import com.google.common.annotations.VisibleForTesting; -import com.google.common.base.Predicate; -import com.google.common.base.Splitter; -import com.google.common.collect.Iterables; -import com.google.common.io.Closeables; -import com.google.inject.Inject; -import com.jcraft.jsch.ChannelExec; -import com.jcraft.jsch.ChannelSftp; -import com.jcraft.jsch.JSch; -import com.jcraft.jsch.JSchException; -import com.jcraft.jsch.Session; -import com.jcraft.jsch.SftpException; - -/** - * This class needs refactoring. It is not thread safe. - * - * @author Adrian Cole - */ -public class JschSshClient implements SshClient { - - private final class CloseFtpChannelOnCloseInputStream extends ProxyInputStream { - - private final ChannelSftp sftp; - - private CloseFtpChannelOnCloseInputStream(InputStream proxy, ChannelSftp sftp) { - super(proxy); - this.sftp = sftp; - } - - @Override - public void close() throws IOException { - super.close(); - if (sftp != null) - sftp.disconnect(); - } - } - - private final String host; - private final int port; - private final String username; - private final String password; - - @Inject(optional = true) - @Named("jclouds.ssh.max_retries") - @VisibleForTesting - int sshRetries = 5; - - @Inject(optional = true) - @Named("jclouds.ssh.retryable_messages") - @VisibleForTesting - String retryableMessages = "invalid data,End of IO Stream Read,Connection reset,connection is closed by foreign host,socket is not established"; - - @Inject(optional = true) - @Named("jclouds.ssh.retry_predicate") - private Predicate retryPredicate = or(instanceOf(ConnectException.class), instanceOf(IOException.class)); - - @Resource - @Named("jclouds.ssh") - protected Logger logger = Logger.NULL; - - private Session session; - private final byte[] privateKey; - final byte[] emptyPassPhrase = new byte[0]; - private final int timeout; - private final BackoffLimitedRetryHandler backoffLimitedRetryHandler; - - public JschSshClient(BackoffLimitedRetryHandler backoffLimitedRetryHandler, IPSocket socket, int timeout, - String username, String password, byte[] privateKey) { - this.host = checkNotNull(socket, "socket").getAddress(); - checkArgument(socket.getPort() > 0, "ssh port must be greater then zero" + socket.getPort()); - checkArgument(password != null || privateKey != null, "you must specify a password or a key"); - this.port = socket.getPort(); - this.username = checkNotNull(username, "username"); - this.backoffLimitedRetryHandler = checkNotNull(backoffLimitedRetryHandler, "backoffLimitedRetryHandler"); - this.timeout = timeout; - this.password = password; - this.privateKey = privateKey; - } - - public Payload get(String path) { - checkNotNull(path, "path"); - - ChannelSftp sftp = getSftp(); - try { - return Payloads.newInputStreamPayload(new CloseFtpChannelOnCloseInputStream(sftp.get(path), sftp)); - } catch (SftpException e) { - throw new SshException(String.format("%s@%s:%d: Error getting path: %s", username, host, port, path), e); - } - } - - @Override - public void put(String path, Payload contents) { - checkNotNull(path, "path"); - checkNotNull(contents, "contents"); - ChannelSftp sftp = getSftp(); - try { - sftp.put(contents.getInput(), path); - } catch (SftpException e) { - throw new SshException(String.format("%s@%s:%d: Error putting path: %s", username, host, port, path), e); - } finally { - Closeables.closeQuietly(contents); - } - } - - @Override - public void put(String path, String contents) { - put(path, Payloads.newStringPayload(checkNotNull(contents, "contents"))); - } - - private ChannelSftp getSftp() { - checkConnected(); - logger.debug("%s@%s:%d: Opening sftp Channel.", username, host, port); - ChannelSftp sftp = null; - try { - sftp = (ChannelSftp) session.openChannel("sftp"); - sftp.connect(); - } catch (JSchException e) { - throw new SshException(String.format("%s@%s:%d: Error connecting to sftp.", username, host, port), e); - } - return sftp; - } - - private void checkConnected() { - checkState(session != null && session.isConnected(), String.format("%s@%s:%d: SFTP not connected!", username, - host, port)); - } - - @PostConstruct - public void connect() { - disconnect(); - Exception e = null; - RETRY_LOOP: for (int i = 0; i < sshRetries; i++) { - try { - newSession(); - e = null; - break RETRY_LOOP; - } catch (Exception from) { - e = from; - disconnect(); - - if (i == sshRetries) - throw propagate(from); - - if (shouldRetry(from)) { - backoffForAttempt(i + 1, String.format("%s@%s:%d: connection error: %s", username, host, port, from - .getMessage())); - continue; - } - - throw propagate(from); - } - } - if (e != null) - throw propagate(e); - } - - @VisibleForTesting - boolean shouldRetry(Exception from) { - final String rootMessage = getRootCause(from).getMessage(); - return any(getCausalChain(from), retryPredicate) - || Iterables.any(Splitter.on(",").split(retryableMessages), new Predicate() { - - @Override - public boolean apply(String input) { - return rootMessage.indexOf(input) != -1; - } - - }); - } - - private void backoffForAttempt(int retryAttempt, String message) { - backoffLimitedRetryHandler.imposeBackoffExponentialDelay(200L, 2, retryAttempt, sshRetries, message); - } - - private void newSession() throws JSchException { - JSch jsch = new JSch(); - session = null; - try { - session = jsch.getSession(username, host, port); - if (timeout != 0) - session.setTimeout(timeout); - logger.debug("%s@%s:%d: Session created.", username, host, port); - if (password != null) { - session.setPassword(password); - } else { - // jsch wipes out your private key - jsch.addIdentity(username, Arrays.copyOf(privateKey, privateKey.length), null, emptyPassPhrase); - } - } catch (JSchException e) { - throw new SshException(String.format("%s@%s:%d: Error creating session.", username, host, port), e); - } - java.util.Properties config = new java.util.Properties(); - config.put("StrictHostKeyChecking", "no"); - session.setConfig(config); - session.connect(); - logger.debug("%s@%s:%d: Session connected.", username, host, port); - } - - private SshException propagate(Exception e) { - throw new SshException(String.format("%s@%s:%d: Error connecting to session.", username, host, port), e); - } - - @PreDestroy - public void disconnect() { - if (session != null && session.isConnected()) { - session.disconnect(); - session = null; - } - } - - public ExecResponse exec(String command) { - checkConnected(); - ChannelExec executor = null; - try { - try { - executor = (ChannelExec) session.openChannel("exec"); - executor.setPty(true); - } catch (JSchException e) { - throw new SshException(String.format("%s@%s:%d: Error connecting to exec.", username, host, port), e); - } - executor.setCommand(command); - ByteArrayOutputStream error = new ByteArrayOutputStream(); - executor.setErrStream(error); - try { - executor.connect(); - String outputString = Strings2.toStringAndClose(executor.getInputStream()); - String errorString = error.toString(); - int errorStatus = executor.getExitStatus(); - int i = 0; - while ((errorStatus = executor.getExitStatus()) == -1 && i < this.sshRetries) - backoffForAttempt(++i, String.format("%s@%s:%d: bad status: -1", username, host, port)); - if (errorStatus == -1) - throw new SshException(String.format("%s@%s:%d: received exit status %d executing %s", username, host, - port, executor.getExitStatus(), command)); - return new ExecResponse(outputString, errorString, errorStatus); - } catch (Exception e) { - throw new SshException(String - .format("%s@%s:%d: Error executing command: %s", username, host, port, command), e); - } - } finally { - if (executor != null) - executor.disconnect(); - } - } - - @Override - public String getHostAddress() { - return this.host; - } - - @Override - public String getUsername() { - return this.username; - } - -} +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.jclouds.ssh.jsch; + +import static com.google.common.base.Preconditions.checkArgument; +import static com.google.common.base.Preconditions.checkNotNull; +import static com.google.common.base.Preconditions.checkState; +import static com.google.common.base.Predicates.instanceOf; +import static com.google.common.base.Predicates.or; +import static com.google.common.base.Throwables.getCausalChain; +import static com.google.common.base.Throwables.getRootCause; +import static com.google.common.collect.Iterables.any; + +import java.io.IOException; +import java.io.InputStream; +import java.net.ConnectException; +import java.util.Arrays; + +import javax.annotation.PostConstruct; +import javax.annotation.PreDestroy; +import javax.annotation.Resource; +import javax.inject.Named; + +import org.apache.commons.io.input.ProxyInputStream; +import org.apache.commons.io.output.ByteArrayOutputStream; +import org.jclouds.compute.domain.ExecResponse; +import org.jclouds.http.handlers.BackoffLimitedRetryHandler; +import org.jclouds.io.Payload; +import org.jclouds.io.Payloads; +import org.jclouds.logging.Logger; +import org.jclouds.net.IPSocket; +import org.jclouds.ssh.SshClient; +import org.jclouds.ssh.SshException; +import org.jclouds.util.Strings2; + +import com.google.common.annotations.VisibleForTesting; +import com.google.common.base.Predicate; +import com.google.common.base.Splitter; +import com.google.common.collect.Iterables; +import com.google.common.io.Closeables; +import com.google.inject.Inject; +import com.jcraft.jsch.ChannelExec; +import com.jcraft.jsch.ChannelSftp; +import com.jcraft.jsch.JSch; +import com.jcraft.jsch.JSchException; +import com.jcraft.jsch.Session; +import com.jcraft.jsch.SftpException; + +/** + * This class needs refactoring. It is not thread safe. + * + * @author Adrian Cole + */ +public class JschSshClient implements SshClient { + + private final class CloseFtpChannelOnCloseInputStream extends ProxyInputStream { + + private final ChannelSftp sftp; + + private CloseFtpChannelOnCloseInputStream(InputStream proxy, ChannelSftp sftp) { + super(proxy); + this.sftp = sftp; + } + + @Override + public void close() throws IOException { + super.close(); + if (sftp != null) + sftp.disconnect(); + } + } + + private final String host; + private final int port; + private final String username; + private final String password; + + @Inject(optional = true) + @Named("jclouds.ssh.max_retries") + @VisibleForTesting + int sshRetries = 5; + + @Inject(optional = true) + @Named("jclouds.ssh.retryable_messages") + @VisibleForTesting + String retryableMessages = "invalid data,End of IO Stream Read,Connection reset,connection is closed by foreign host,socket is not established"; + + @Inject(optional = true) + @Named("jclouds.ssh.retry_predicate") + private Predicate retryPredicate = or(instanceOf(ConnectException.class), instanceOf(IOException.class)); + + @Resource + @Named("jclouds.ssh") + protected Logger logger = Logger.NULL; + + private Session session; + private final byte[] privateKey; + final byte[] emptyPassPhrase = new byte[0]; + private final int timeout; + private final BackoffLimitedRetryHandler backoffLimitedRetryHandler; + + public JschSshClient(BackoffLimitedRetryHandler backoffLimitedRetryHandler, IPSocket socket, int timeout, + String username, String password, byte[] privateKey) { + this.host = checkNotNull(socket, "socket").getAddress(); + checkArgument(socket.getPort() > 0, "ssh port must be greater then zero" + socket.getPort()); + checkArgument(password != null || privateKey != null, "you must specify a password or a key"); + this.port = socket.getPort(); + this.username = checkNotNull(username, "username"); + this.backoffLimitedRetryHandler = checkNotNull(backoffLimitedRetryHandler, "backoffLimitedRetryHandler"); + this.timeout = timeout; + this.password = password; + this.privateKey = privateKey; + } + + public Payload get(String path) { + checkNotNull(path, "path"); + + ChannelSftp sftp = getSftp(); + try { + return Payloads.newInputStreamPayload(new CloseFtpChannelOnCloseInputStream(sftp.get(path), sftp)); + } catch (SftpException e) { + throw new SshException(String.format("%s@%s:%d: Error getting path: %s", username, host, port, path), e); + } + } + + @Override + public void put(String path, Payload contents) { + checkNotNull(path, "path"); + checkNotNull(contents, "contents"); + ChannelSftp sftp = getSftp(); + try { + sftp.put(contents.getInput(), path); + } catch (SftpException e) { + throw new SshException(String.format("%s@%s:%d: Error putting path: %s", username, host, port, path), e); + } finally { + Closeables.closeQuietly(contents); + } + } + + @Override + public void put(String path, String contents) { + put(path, Payloads.newStringPayload(checkNotNull(contents, "contents"))); + } + + private ChannelSftp getSftp() { + checkConnected(); + logger.debug("%s@%s:%d: Opening sftp Channel.", username, host, port); + ChannelSftp sftp = null; + try { + sftp = (ChannelSftp) session.openChannel("sftp"); + sftp.connect(); + } catch (JSchException e) { + throw new SshException(String.format("%s@%s:%d: Error connecting to sftp.", username, host, port), e); + } + return sftp; + } + + private void checkConnected() { + checkState(session != null && session.isConnected(), String.format("%s@%s:%d: SFTP not connected!", username, + host, port)); + } + + @PostConstruct + public void connect() { + disconnect(); + Exception e = null; + RETRY_LOOP: for (int i = 0; i < sshRetries; i++) { + try { + newSession(); + e = null; + break RETRY_LOOP; + } catch (Exception from) { + e = from; + disconnect(); + + if (i == sshRetries) + throw propagate(from); + + if (shouldRetry(from)) { + backoffForAttempt(i + 1, String.format("%s@%s:%d: connection error: %s", username, host, port, from + .getMessage())); + continue; + } + + throw propagate(from); + } + } + if (e != null) + throw propagate(e); + } + + @VisibleForTesting + boolean shouldRetry(Exception from) { + final String rootMessage = getRootCause(from).getMessage(); + return any(getCausalChain(from), retryPredicate) + || Iterables.any(Splitter.on(",").split(retryableMessages), new Predicate() { + + @Override + public boolean apply(String input) { + return rootMessage.indexOf(input) != -1; + } + + }); + } + + private void backoffForAttempt(int retryAttempt, String message) { + backoffLimitedRetryHandler.imposeBackoffExponentialDelay(200L, 2, retryAttempt, sshRetries, message); + } + + private void newSession() throws JSchException { + JSch jsch = new JSch(); + session = null; + try { + session = jsch.getSession(username, host, port); + if (timeout != 0) + session.setTimeout(timeout); + logger.debug("%s@%s:%d: Session created.", username, host, port); + if (password != null) { + session.setPassword(password); + } else { + // jsch wipes out your private key + jsch.addIdentity(username, Arrays.copyOf(privateKey, privateKey.length), null, emptyPassPhrase); + } + } catch (JSchException e) { + throw new SshException(String.format("%s@%s:%d: Error creating session.", username, host, port), e); + } + java.util.Properties config = new java.util.Properties(); + config.put("StrictHostKeyChecking", "no"); + session.setConfig(config); + session.connect(); + logger.debug("%s@%s:%d: Session connected.", username, host, port); + } + + private SshException propagate(Exception e) { + throw new SshException(String.format("%s@%s:%d: Error connecting to session.", username, host, port), e); + } + + @PreDestroy + public void disconnect() { + if (session != null && session.isConnected()) { + session.disconnect(); + session = null; + } + } + + public ExecResponse exec(String command) { + checkConnected(); + + ChannelExec executor = null; + ByteArrayOutputStream error = null; + + int j = 0; + do { + try { + executor = (ChannelExec) session.openChannel("exec"); + } catch (JSchException e) { + // unrecoverable fail because ssh session closed + throw new SshException(String.format("%s@%s:%d: Error connecting to exec.", username, host, port), e); + } + + error = new ByteArrayOutputStream(); + executor.setPty(true); + executor.setCommand(command); + executor.setErrStream(error); + + try { + executor.connect(); + } catch (JSchException e) { + executor.disconnect(); + backoffForAttempt(++j, String.format("%s@%s:%d: Failed to connect ChannelExec", username, host, port)); + } + } while (j < this.sshRetries && !executor.isConnected()); + + if (!executor.isConnected()) + throw new SshException(String.format("%s@%s:%d: Failed to connect ChannelExec executing %s", + username, host, port, command)); + + try { + String outputString = Strings2.toStringAndClose(executor.getInputStream()); + String errorString = error.toString(); + int errorStatus = executor.getExitStatus(); + int i = 0; + while ((errorStatus = executor.getExitStatus()) == -1 && i < this.sshRetries) + backoffForAttempt(++i, String.format("%s@%s:%d: bad status: -1", username, host, port)); + if (errorStatus == -1) + throw new SshException(String.format("%s@%s:%d: received exit status %d executing %s", username, host, + port, executor.getExitStatus(), command)); + return new ExecResponse(outputString, errorString, errorStatus); + } catch (Exception e) { + throw new SshException(String + .format("%s@%s:%d: Error executing command: %s", username, host, port, command), e); + } + finally { + executor.disconnect(); + } + } + + @Override + public String getHostAddress() { + return this.host; + } + + @Override + public String getUsername() { + return this.username; + } + +} \ No newline at end of file From acffe37459e83ab3d93b713ec6a56766087ead0d Mon Sep 17 00:00:00 2001 From: Jeremy Whitlock Date: Wed, 1 Jun 2011 23:37:39 -0600 Subject: [PATCH 006/264] Issue 550: Added ProviderMetadata for Google Storage. [in providers/googlestorage/src] * main/java/org/jclouds/googlestorage/GoogleStorageProviderMetadata.java, main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata, test/java/org/jclouds/googlestorage/GoogleStorageProviderTest.java: Added. --- .../GoogleStorageProviderMetadata.java | 108 ++++++++++++++++++ .../org.jclouds.providers.ProviderMetadata | 1 + .../GoogleStorageProviderTest.java | 37 ++++++ 3 files changed, 146 insertions(+) create mode 100644 providers/googlestorage/src/main/java/org/jclouds/googlestorage/GoogleStorageProviderMetadata.java create mode 100644 providers/googlestorage/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata create mode 100644 providers/googlestorage/src/test/java/org/jclouds/googlestorage/GoogleStorageProviderTest.java diff --git a/providers/googlestorage/src/main/java/org/jclouds/googlestorage/GoogleStorageProviderMetadata.java b/providers/googlestorage/src/main/java/org/jclouds/googlestorage/GoogleStorageProviderMetadata.java new file mode 100644 index 0000000000..65ab1e30a0 --- /dev/null +++ b/providers/googlestorage/src/main/java/org/jclouds/googlestorage/GoogleStorageProviderMetadata.java @@ -0,0 +1,108 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.jclouds.googlestorage; + +import com.google.common.collect.ImmutableSet; + +import java.net.URI; +import java.util.Set; + +import org.jclouds.providers.BaseProviderMetadata; + +/** + * Implementation of {@ link org.jclouds.types.ProviderMetadata} for Google's + * Storage provider. + * + * @author Jeremy Whitlock + */ +public class GoogleStorageProviderMetadata extends BaseProviderMetadata { + + /** + * {@inheritDoc} + */ + @Override + public String getId() { + return "googlestorage"; + } + + /** + * {@inheritDoc} + */ + @Override + public String getType() { + return BLOBSTORE_TYPE; + } + + /** + * {@inheritDoc} + */ + @Override + public String getName() { + return "Google Storage"; + } + + /** + * {@inheritDoc} + */ + @Override + public String getIdentityName() { + return "Access Key"; + } + + /** + * {@inheritDoc} + */ + @Override + public String getCredentialName() { + return "Secret Key"; + } + + /** + * {@inheritDoc} + */ + @Override + public URI getHomepage() { + return URI.create("http://code.google.com/apis/storage/"); + } + + /** + * {@inheritDoc} + */ + @Override + public URI getConsole() { + return URI.create("https://code.google.com/apis/console#:storage:access"); + } + + /** + * {@inheritDoc} + */ + @Override + public URI getApiDocumentation() { + return URI.create("http://code.google.com/apis/storage/docs/reference-guide.html"); + } + + /** + * {@inheritDoc} + */ + @Override + public Set getIso3166Codes() { + return ImmutableSet.of("US"); + } + +} diff --git a/providers/googlestorage/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata b/providers/googlestorage/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata new file mode 100644 index 0000000000..01a8afea14 --- /dev/null +++ b/providers/googlestorage/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata @@ -0,0 +1 @@ +org.jclouds.googlestorage.GoogleStorageProviderMetadata diff --git a/providers/googlestorage/src/test/java/org/jclouds/googlestorage/GoogleStorageProviderTest.java b/providers/googlestorage/src/test/java/org/jclouds/googlestorage/GoogleStorageProviderTest.java new file mode 100644 index 0000000000..1ac07495ce --- /dev/null +++ b/providers/googlestorage/src/test/java/org/jclouds/googlestorage/GoogleStorageProviderTest.java @@ -0,0 +1,37 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.jclouds.googlestorage; + +import org.jclouds.providers.BaseProviderMetadataTest; +import org.jclouds.providers.ProviderMetadata; +import org.testng.annotations.Test; + +/** + * The GoogleStorageProviderTest tests the {@link GoogleStorageProviderMetadata} class. + * + * @author Jeremy Whitlock + */ +@Test(groups = "unit", testName = "GoogleStorageProviderTest") +public class GoogleStorageProviderTest extends BaseProviderMetadataTest { + + public GoogleStorageProviderTest() { + super(new GoogleStorageProviderMetadata(), ProviderMetadata.BLOBSTORE_TYPE); + } + +} \ No newline at end of file From 36cc3805b5d66c91a2faa959bf4e4e54d92aa266 Mon Sep 17 00:00:00 2001 From: Mattias Holmqvist Date: Thu, 2 Jun 2011 12:11:23 +0200 Subject: [PATCH 007/264] First version of ebs2.clj --- .../src/main/clojure/org/jclouds/ec2/ebs2.clj | 290 ++++++++++++++++++ 1 file changed, 290 insertions(+) create mode 100644 apis/ec2/src/main/clojure/org/jclouds/ec2/ebs2.clj diff --git a/apis/ec2/src/main/clojure/org/jclouds/ec2/ebs2.clj b/apis/ec2/src/main/clojure/org/jclouds/ec2/ebs2.clj new file mode 100644 index 0000000000..854bdb36fa --- /dev/null +++ b/apis/ec2/src/main/clojure/org/jclouds/ec2/ebs2.clj @@ -0,0 +1,290 @@ +; +; +; Copyright (C) 2011 Cloud Conscious, LLC. +; +; ==================================================================== +; Licensed under the Apache License, Version 2.0 (the "License"); +; you may not use this file except in compliance with the License. +; You may obtain a copy of the License at +; +; http://www.apache.org/licenses/LICENSE-2.0 +; +; Unless required by applicable law or agreed to in writing, software +; distributed under the License is distributed on an "AS IS" BASIS, +; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +; See the License for the specific language governing permissions and +; limitations under the License. +; ==================================================================== +; + +(ns + #^{:author "Chas Emerick, cemerick@snowtide.com" + :doc "A clojure binding to the jclouds EBS service interface."} + org.jclouds.ec2.ebs2 + (:use [org.jclouds.compute2]) + (:use (clojure.contrib def core)) + (:import org.jclouds.aws.domain.Region + org.jclouds.compute.domain.NodeMetadata + (org.jclouds.ec2.domain Volume Volume$Status Snapshot Snapshot$Status AvailabilityZoneInfo) + (org.jclouds.ec2.options DescribeSnapshotsOptions DetachVolumeOptions CreateSnapshotOptions))) +(defn snapshot? + "Returns true iff the argument is a org.jclouds.ec2.domain.Snapshot." + [s] + (instance? Snapshot s)) + +(defn volume? + "Returns true iff the argument is a org.jclouds.ec2.domain.Volume." + [v] + (instance? Volume v)) + +(defn #^org.jclouds.ec2.services.ElasticBlockStoreClient + ebs-service + "" + [compute] + (-> compute + .getContext + .getProviderSpecificContext + .getApi + .getElasticBlockStoreServices)) + +(defn get-region + "Coerces the first parameter into a Region string; strings, keywords, and + NodeMetadata instances are acceptable arguments. An optional second argument + is returned if the first cannot be coerced into a region string. + Returns nil otherwise." + ([v] (get-region v nil)) + ([v default-region] + (cond + (string? v) v + (keyword? v) (name v) + (instance? NodeMetadata v) (let [zone (location v)] + ; no easier way to go from zone -> region? + (if (> (.indexOf zone "-") -1) + (subs zone 0 (-> zone count dec)) + zone)) + :else default-region))) + +(defn get-volume-id + "Returns a string volume ID taken from the given string, keyword, or Volume argument." + [v] + (cond + (instance? Volume v) (.getId #^Volume v) + (keyword? v) (name v) + (string? v) v + :else (throw (IllegalArgumentException. + (str "Can't obtain volume id from argument of type " (class v)))))) + +(defn volumes + "Returns a set of org.jclouds.ec2.domain.Volume instances corresponding to the + volumes in the specified region (defaulting to your account's default region)." + + [compute & [region & volume-ids]] + (set + (.describeVolumesInRegion (ebs-service compute) + (get-region region) + (into-array String (map get-volume-id + (if (get-region region) + volume-ids + (when region (cons region volume-ids)))))))) +(defn- as-string + [v] + (cond + (string? v) v + (keyword? v) (name v) + :else v)) +(defn- get-string + [map key] + (as-string (get map key))) +(defn- as-int + [v] + (cond + (number? v) (int v) + (string? v) (Integer/parseInt v) + :else (throw (IllegalArgumentException. + (str "Don't know how to convert object of type " (class v) " to a string"))))) + +(defn- snapshot-options + [optmap] + (let [string-array #(let [v (% optmap)] + (into-array String (cond + (keyword? v) [(name v)] + (string? v) [v] + :else (map as-string v))))] + (-> (DescribeSnapshotsOptions.) + (.ownedBy (string-array :owner)) + (.snapshotIds (string-array :ids)) + (.restorableBy (string-array :restorable-by))))) + +(defn snapshots + "Returns a set of org.jclouds.aws.ec2.domain.Snapshot instances that match + the criteria provided. Options include: + + :region - region string, keyword, or NodeMetadata + :owner - AWS account id (or \"amazon\" or \"self\") + :restorable-by - AWS account id + + Multiple values for each type of criteria can be provided by passing a seq + of the appropriate types as values." + [compute & options] + (let [options (apply hash-map options) + region (:region options) + options (snapshot-options (dissoc options :region))] + (set + (.describeSnapshotsInRegion (ebs-service compute) + (get-region region) + (into-array DescribeSnapshotsOptions [options]))))) + +(defn create-snapshot + "Creates a snapshot of a volume in the specified region with an optional description. + If provided, the description must be < 255 characters in length. Returns the + org.jclouds.aws.ec2.domain.Snapshot object representing the created snapshot." + + ([computess #^Volume volume] (create-snapshot computess volume nil)) + ([compute #^Volume volume description] (create-snapshot compute (.getRegion volume) (.getId volume) description)) + ([compute region volume-id description] + (.createSnapshotInRegion (ebs-service compute) + (get-region region) + (as-string volume-id) + (into-array CreateSnapshotOptions (when description + [(.withDescription (CreateSnapshotOptions.) description)]))))) + +(defn delete-snapshot + "Deletes a snapshot in the specified region." + ([compute #^Snapshot snapshot] (delete-snapshot compute (.getRegion snapshot) (.getId snapshot))) + ([compute region snapshot-id] + (.deleteSnapshotInRegion (ebs-service compute) + (get-region region) + (as-string snapshot-id)))) + +(defn get-zone + [v] + (cond + (instance? AvailabilityZoneInfo v) (.getZone v) + (instance? NodeMetadata v) (location #^NodeMetadata v) + (string? v) v + (keyword? v) (name v) + :else (throw (IllegalArgumentException. + (str "Can't obtain zone from argument of type " (class v)))))) + +(defn attach-volume + "Attaches a volume to an instance, returning the resulting org.jclouds.aws.ec2.domain.Attachment." + ([compute #^NodeMetadata node volume device] + (attach-volume compute node (.getProviderId node) (get-volume-id volume) device)) + ([compute region instance-id volume-id device] + (apply #(.attachVolumeInRegion (ebs-service compute) + (get-region region) % %2 %3) + (map as-string [volume-id instance-id device])))) + +(defn detach-volume + "Detaches a volume from the instance to which it is currently attached. + The volume may be specified with a Volume instance, a string, or a keyword. + Providing a logical true value for the :force option will cause the volume + to be forcibly detached, regardless of whether it is in-use (mounted) or not. + + If the volume is specified as a string or keyword, one of the following options + is additionally required: + + :region - the region where the volume is allocated + :node - a node in the region where the volume is allocated + + FYI: It appears that issuing a detatch-volume command while the volume in question is mounted + will cause the volume to be detatched immediately upon the volume beign unmounted." + [compute volume & options] + (let [options (apply hash-map options) + volume-id (get-volume-id volume) + region (get-region (if (instance? Volume volume) + (.getRegion volume) + (or (:region options) (:node options))))] + (when (not region) + (throw (IllegalArgumentException. + "Must specify volume's region via :region or :node options, or by providing a Volume instance."))) + (.detachVolumeInRegion (ebs-service compute) + region + volume-id + (boolean (:force options)) + (into-array DetachVolumeOptions [])))) + +(defn create-volume + "Creates a new volume given a set of options: + + - one of :zone (keyword, string, or AvailabilityZoneInfo) or :node (NodeMetadata) + - one or both of :snapshot (keyword, string, or Snapshot instance) or :size + (string, keyword, or number) + - :device (string or keyword) provided *only* when you want to attach the new volume to + the :node you specified! + + Returns a vector of [created org.jclouds.ec2.domain.Volume, + optional org.jclouds.ec2.domain.Attachment] + + Note that specifying :node instead of :zone will only attach the created volume + :device is also provided. Otherwise, the node is only used to obtain the desired + availability zone. + + Note also that if :device and :node are specified, and the attach operation fails, + you will have \"leaked\" the newly-created volume + (volume creation and attachment cannot be done atomically)." + + [compute & options] + (when (-> options count odd?) + (throw (IllegalArgumentException. "Must provide key-value pairs, e.g. :zone :us-east-1d :size 200"))) + (let [options (apply hash-map options) + snapshot (get-string options :snapshot) + snapshot (if (snapshot? snapshot) (.getId snapshot) snapshot) + size (-?> (get-string options :size) as-int) + #^NodeMetadata node (:node options) + zone (or node (get-string options :zone)) + zone (if zone + (get-zone zone) + (throw (IllegalArgumentException. "Must supply a :zone or :node option."))) + ebs (ebs-service compute)] + (when (and (:device options) (not node)) + (throw (IllegalArgumentException. "Cannot create and attach new volume; no :node specified"))) + (let [new-volume (cond + (and snapshot size) (.createVolumeFromSnapshotInAvailabilityZone ebs zone size snapshot) + snapshot (.createVolumeFromSnapshotInAvailabilityZone ebs zone snapshot) + size (.createVolumeInAvailabilityZone ebs zone size) + :else (throw (IllegalArgumentException. "Must supply :size and/or :snapshot options.")))] + [new-volume (when (:device options) + (attach-volume compute node new-volume (as-string (:device options))))]))) + +(defn delete-volume + "Deletes a volume in the specified region." + ([compute #^Volume volume] + (delete-volume (.getRegion volume) (.getId volume))) + ([compute region volume-id] + (.deleteVolumeInRegion (ebs-service compute) + (get-region region) + (as-string volume-id)))) + +(defn status + "Returns the status of the given entity; works for Volumes and Snapshots." + [k] + (.getStatus k)) + +(defn status-available? + [#^Volume v] + (= Volume$Status/AVAILABLE (status v))) + +(defn status-creating? + [#^Volume v] + (= Volume$Status/CREATING (status v))) + +(defn status-deleting? + [#^Volume v] + (= Volume$Status/DELETING (status v))) + +(defn status-in-use? + [#^Volume v] + (= Volume$Status/IN_USE (status v))) + +(defn status-completed? + [#^Snapshot s] + (= Snapshot$Status/COMPLETED (status s))) + +(defn status-error? + [#^Snapshot s] + (= Snapshot$Status/ERROR (status s))) + +(defn status-pending? + [#^Snapshot s] + (= Snapshot$Status/PENDING (status s))) \ No newline at end of file From ea206d403674a553c158c0e6839f0fdf59f1ae6a Mon Sep 17 00:00:00 2001 From: Dmitri Babaev Date: Thu, 2 Jun 2011 14:25:16 +0400 Subject: [PATCH 008/264] comments for JschSshClinet bug fix --- .../jsch/src/main/java/org/jclouds/ssh/jsch/JschSshClient.java | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/jsch/src/main/java/org/jclouds/ssh/jsch/JschSshClient.java b/drivers/jsch/src/main/java/org/jclouds/ssh/jsch/JschSshClient.java index 9e0d01244e..266567dbbe 100644 --- a/drivers/jsch/src/main/java/org/jclouds/ssh/jsch/JschSshClient.java +++ b/drivers/jsch/src/main/java/org/jclouds/ssh/jsch/JschSshClient.java @@ -282,6 +282,7 @@ public class JschSshClient implements SshClient { try { executor.connect(); } catch (JSchException e) { + // performing a retry if connect has thrown an exception executor.disconnect(); backoffForAttempt(++j, String.format("%s@%s:%d: Failed to connect ChannelExec", username, host, port)); } From f73b46965b31d3847a5da8015099dd27b857a66f Mon Sep 17 00:00:00 2001 From: Mattias Holmqvist Date: Thu, 2 Jun 2011 12:45:52 +0200 Subject: [PATCH 009/264] First version of elastic_ip2.clj --- .../clojure/org/jclouds/ec2/elastic_ip2.clj | 84 +++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 apis/ec2/src/main/clojure/org/jclouds/ec2/elastic_ip2.clj diff --git a/apis/ec2/src/main/clojure/org/jclouds/ec2/elastic_ip2.clj b/apis/ec2/src/main/clojure/org/jclouds/ec2/elastic_ip2.clj new file mode 100644 index 0000000000..660f4db498 --- /dev/null +++ b/apis/ec2/src/main/clojure/org/jclouds/ec2/elastic_ip2.clj @@ -0,0 +1,84 @@ +; +; +; Copyright (C) 2011 Cloud Conscious, LLC. +; +; ==================================================================== +; Licensed under the Apache License, Version 2.0 (the "License"); +; you may not use this file except in compliance with the License. +; You may obtain a copy of the License at +; +; http://www.apache.org/licenses/LICENSE-2.0 +; +; Unless required by applicable law or agreed to in writing, software +; distributed under the License is distributed on an "AS IS" BASIS, +; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +; See the License for the specific language governing permissions and +; limitations under the License. +; ==================================================================== +; + +(ns + #^{:author "Chas Emerick, cemerick@snowtide.com" + :doc "A clojure binding for the jclouds AWS elastic IP address interface."} + org.jclouds.ec2.elastic-ip2 + (:require (org.jclouds [compute2 :as compute]) + [org.jclouds.ec2.ebs :as ebs]) + (:use (clojure.contrib def core)) + (:import org.jclouds.compute.domain.NodeMetadata + (org.jclouds.ec2.domain PublicIpInstanceIdPair))) + +(defn #^org.jclouds.ec2.services.ElasticIPAddressClient + eip-service + "Returns the synchronous ElasticIPAddressClient associated with + the specified compute service, or compute/*compute* as bound by with-compute-service." + [compute] + (-> compute + .getContext .getProviderSpecificContext .getApi .getElasticIPAddressServices)) + +(defn allocate + "Claims a new elastic IP address within the (optionally) specified region for your account. + Region may be a string, keyword, or a node from which the region + is inferred. Returns the IP address as a string." + ([compute] (allocate compute nil)) + ([compute region] + (.allocateAddressInRegion (eip-service compute) (ebs/get-region region)))) + +(defn associate + "Associates an elastic IP address with a node." + ([compute #^NodeMetadata node public-ip] + (associate node public-ip (.getProviderId node))) + ([compute region public-ip instance-id] + (.associateAddressInRegion (eip-service compute) + (ebs/get-region region) + public-ip + instance-id))) + +(defn addresses + "Returns a map of elastic IP addresses to maps with slots: + + :region - the region (string/keyword/NodeMetadata) the IP address is allocated within + :node-id - the ID of the instance with which the IP address is associated (optional) + + You may optionally specify which IP addresses you would like to query." + ([compute] (addresses compute nil)) + ([compute region & public-ips] + (into {} (for [#^PublicIpInstanceIdPair pair (.describeAddressesInRegion (eip-service compute) + (ebs/get-region region) + (into-array String public-ips))] + [(.getPublicIp pair) (merge {:region (.getRegion pair)} + (when (.getInstanceId pair) {:node-id (.getInstanceId pair)}))])))) + +(defn dissociate + "Dissociates an elastic IP address from the node with which it is currently associated." + [compute region public-ip] + (.disassociateAddressInRegion (eip-service compute) + (ebs/get-region region) + public-ip)) + +(defn release + "Disclaims an elastic IP address from your account." + ([compute public-ip] (release compute nil public-ip)) + ([compute region public-ip] + (.releaseAddressInRegion (eip-service compute) + (ebs/get-region region) + public-ip))) From c330e100f0c574e3b2a2ebe7a1e5fe32338e2d4b Mon Sep 17 00:00:00 2001 From: Mattias Holmqvist Date: Thu, 2 Jun 2011 14:00:02 +0200 Subject: [PATCH 010/264] Fixed typo --- apis/ec2/src/main/clojure/org/jclouds/ec2/ebs2.clj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apis/ec2/src/main/clojure/org/jclouds/ec2/ebs2.clj b/apis/ec2/src/main/clojure/org/jclouds/ec2/ebs2.clj index 854bdb36fa..ed7be97a54 100644 --- a/apis/ec2/src/main/clojure/org/jclouds/ec2/ebs2.clj +++ b/apis/ec2/src/main/clojure/org/jclouds/ec2/ebs2.clj @@ -139,7 +139,7 @@ If provided, the description must be < 255 characters in length. Returns the org.jclouds.aws.ec2.domain.Snapshot object representing the created snapshot." - ([computess #^Volume volume] (create-snapshot computess volume nil)) + ([compute #^Volume volume] (create-snapshot compute volume nil)) ([compute #^Volume volume description] (create-snapshot compute (.getRegion volume) (.getId volume) description)) ([compute region volume-id description] (.createSnapshotInRegion (ebs-service compute) From 7e4029136e1e7ed081d3f8147cef20896bda46b8 Mon Sep 17 00:00:00 2001 From: Dmitri Babaev Date: Thu, 2 Jun 2011 16:53:12 +0400 Subject: [PATCH 011/264] live tests bug fixes --- .../compute/NovaComputeServiceLiveTest.java | 4 +- .../nova/live/novaclient/ClientBase.java | 2 +- .../live/novaclient/NovaClientLiveTest.java | 762 +++++++++--------- 3 files changed, 383 insertions(+), 385 deletions(-) diff --git a/apis/nova/src/test/java/org/jclouds/openstack/nova/live/compute/NovaComputeServiceLiveTest.java b/apis/nova/src/test/java/org/jclouds/openstack/nova/live/compute/NovaComputeServiceLiveTest.java index b3d6690b27..eea284b089 100644 --- a/apis/nova/src/test/java/org/jclouds/openstack/nova/live/compute/NovaComputeServiceLiveTest.java +++ b/apis/nova/src/test/java/org/jclouds/openstack/nova/live/compute/NovaComputeServiceLiveTest.java @@ -129,7 +129,7 @@ public class NovaComputeServiceLiveTest extends ComputeBase { .family(OsFamily.UBUNTU).description("ffoo").build())); } - @Test(expectedExceptions = JSchException.class, expectedExceptionsMessageRegExp = "Auth fail", timeOut = 60000) + @Test(expectedExceptions = JSchException.class, expectedExceptionsMessageRegExp = "Auth fail", timeOut = 120000) void testScriptExecutionWithWrongCredentials() throws Throwable, RunScriptOnNodesException, URISyntaxException, InterruptedException { NodeMetadata node = getDefaultNodeImmediately(group); String address = awaitForPublicAddressAssigned(node.getId()); @@ -242,7 +242,7 @@ public class NovaComputeServiceLiveTest extends ComputeBase { return templateBuilder.build(); } - @Test(timeOut = 60000) + @Test(timeOut = 120000) public void testGetNodeMetadata() throws Exception { Set nodes = Sets.newHashSet(getDefaultNodeImmediately(group)); awaitForPublicAddressAssigned(nodes.iterator().next().getId()); diff --git a/apis/nova/src/test/java/org/jclouds/openstack/nova/live/novaclient/ClientBase.java b/apis/nova/src/test/java/org/jclouds/openstack/nova/live/novaclient/ClientBase.java index d97177b3bf..e5755c0a53 100644 --- a/apis/nova/src/test/java/org/jclouds/openstack/nova/live/novaclient/ClientBase.java +++ b/apis/nova/src/test/java/org/jclouds/openstack/nova/live/novaclient/ClientBase.java @@ -84,7 +84,7 @@ public class ClientBase { return createDefaultServer(defaultName); } - private Server createDefaultServer(String serverName) { + protected Server createDefaultServer(String serverName) { String imageRef = client.getImage(testImageId).getURI().toASCIIString(); String flavorRef = client.getFlavor(1).getURI().toASCIIString(); diff --git a/apis/nova/src/test/java/org/jclouds/openstack/nova/live/novaclient/NovaClientLiveTest.java b/apis/nova/src/test/java/org/jclouds/openstack/nova/live/novaclient/NovaClientLiveTest.java index be0ba6af9f..d6da4aed0e 100644 --- a/apis/nova/src/test/java/org/jclouds/openstack/nova/live/novaclient/NovaClientLiveTest.java +++ b/apis/nova/src/test/java/org/jclouds/openstack/nova/live/novaclient/NovaClientLiveTest.java @@ -1,382 +1,380 @@ -/** - * - * Copyright (C) 2011 Cloud Conscious, LLC. - * - * ==================================================================== - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ==================================================================== - */ - -package org.jclouds.openstack.nova.live.novaclient; - -import com.google.common.collect.Iterables; -import org.jclouds.domain.Credentials; -import org.jclouds.http.HttpResponseException; -import org.jclouds.io.Payload; -import org.jclouds.net.IPSocket; -import org.jclouds.openstack.nova.domain.*; -import org.jclouds.openstack.nova.options.RebuildServerOptions; -import org.jclouds.ssh.SshClient; -import org.jclouds.util.Strings2; -import org.testng.annotations.AfterTest; -import org.testng.annotations.Test; - -import java.io.IOException; -import java.util.Set; - -import static org.jclouds.openstack.nova.options.ListOptions.Builder.withDetails; -import static org.testng.Assert.*; - -/** - * Tests behavior of {@code NovaClient} - * - * @author Adrian Cole - */ -// disabled [Web Hosting #129069 -@Test(groups = "live", sequential = true) -public class NovaClientLiveTest extends ClientBase { - - - @Test - public void testListServers() throws Exception { - Set response = client.listServers(); - assert null != response; - long initialContainerCount = response.size(); - assertTrue(initialContainerCount >= 0); - } - - @Test - public void testListServersDetail() throws Exception { - Set response = client.listServers(withDetails()); - assert null != response; - long initialContainerCount = response.size(); - assertTrue(initialContainerCount >= 0); - } - - @Test - public void testListImages() throws Exception { - Set response = client.listImages(); - assert null != response; - long imageCount = response.size(); - assertTrue(imageCount >= 1); - for (Image image : response) { - assertTrue(image.getId() >= 0); - assert null != image.getName() : image; - } - - } - - @Test - public void testListImagesDetail() throws Exception { - Set response = client.listImages(withDetails()); - assert null != response; - long imageCount = response.size(); - assertTrue(imageCount >= 0); - for (Image image : response) { - assertTrue(image.getId() >= 1); - assert null != image.getName() : image; - assert null != image.getStatus() : image; - } - } - - @Test - public void testGetImagesDetail() throws Exception { - Set response = client.listImages(withDetails()); - assert null != response; - long imageCount = response.size(); - assertTrue(imageCount >= 0); - for (Image image : response) { - try { - Image newDetails = client.getImage(image.getId()); - assertEquals(image, newDetails); - } catch (HttpResponseException e) {// Ticket #9867 - if (e.getResponse().getStatusCode() != 400) - throw e; - } - } - } - - @Test - public void testGetImageDetailsNotFound() throws Exception { - assert client.getImage(12312987) == null; - } - - @Test - public void testGetServerDetailsNotFound() throws Exception { - assert client.getServer(12312987) == null; - } - - @Test - public void testGetServersDetail() throws Exception { - Set response = client.listServers(withDetails()); - assert null != response; - assertTrue(response.size() >= 0); - for (Server server : response) { - Server newDetails = client.getServer(server.getId()); - System.out.println("===="); - - System.out.println(server); - System.out.println(newDetails); - System.out.println("===="); - } - for (Server server : response) { - Server newDetails = client.getServer(server.getId()); - assertEquals(server, newDetails); - } - } - - @Test - public void testListFlavors() throws Exception { - Set response = client.listFlavors(); - assert null != response; - long flavorCount = response.size(); - assertTrue(flavorCount >= 1); - for (Flavor flavor : response) { - assertTrue(flavor.getId() >= 0); - assert null != flavor.getName() : flavor; - } - - } - - @Test - public void testListFlavorsDetail() throws Exception { - Set response = client.listFlavors(withDetails()); - assert null != response; - long flavorCount = response.size(); - assertTrue(flavorCount >= 0); - for (Flavor flavor : response) { - assertTrue(flavor.getId() >= 1); - assert null != flavor.getName() : flavor; - assert null != flavor.getDisk() : flavor; - assert null != flavor.getRam() : flavor; - } - } - - @Test - public void testGetFlavorsDetail() throws Exception { - Set response = client.listFlavors(withDetails()); - assert null != response; - long flavorCount = response.size(); - assertTrue(flavorCount >= 0); - for (Flavor flavor : response) { - Flavor newDetails = client.getFlavor(flavor.getId()); - assertEquals(flavor, newDetails); - } - } - - @Test - public void testGetFlavorDetailsNotFound() throws Exception { - assert client.getFlavor(12312987) == null; - } - - - @Test(enabled = true) - public void testCreateServer() throws Exception { - Server server = getDefaultServerImmediately(); - assertNotNull(server.getAdminPass()); - assertEquals(server.getStatus(), ServerStatus.BUILD); - int serverId = server.getId(); - @SuppressWarnings("unused") - String adminPass = server.getAdminPass(); - blockUntilServerActive(serverId); - blockUntilPublicAddress(serverId); - client.getServer(serverId).getAddresses().getPublicAddresses().iterator().next().getAddress(); - } - - private void blockUntilPublicAddress(int serverId) throws InterruptedException { - while (client.getServer(serverId).getAddresses().getPublicAddresses().isEmpty()) { - System.out.println("Awaiting public address"); - Thread.sleep(1000); - } - } - - private void blockUntilServerActive(int serverId) throws InterruptedException { - Server currentDetails; - for (currentDetails = client.getServer(serverId); currentDetails.getStatus() != ServerStatus.ACTIVE; currentDetails = client - .getServer(serverId)) { - System.out.printf("blocking on status active%n%s%n", currentDetails); - Thread.sleep(5 * 1000); - } - } - - private void blockUntilServerVerifyResize(int serverId) throws InterruptedException { - Server currentDetails; - for (currentDetails = client.getServer(serverId); currentDetails.getStatus() != ServerStatus.VERIFY_RESIZE; currentDetails = client - .getServer(serverId)) { - System.out.printf("blocking on status verify resize%n%s%n", currentDetails); - Thread.sleep(5 * 1000); - } - } - - private void blockUntilImageActive(int createdImageId) throws InterruptedException { - Image currentDetails; - for (currentDetails = client.getImage(createdImageId); currentDetails.getStatus() != ImageStatus.ACTIVE; currentDetails = client - .getImage(createdImageId)) { - System.out.printf("blocking on status active%n%s%n", currentDetails); - Thread.sleep(5 * 1000); - } - } - - @Test(enabled = true, timeOut = 300000) - public void testServerDetails() throws Exception { - Server server = getDefaultServerImmediately(); - assertNotNull(server.getHostId(), "Host id: "); - assertEquals(server.getStatus(), ServerStatus.ACTIVE); - assertNotNull(server.getAddresses()); - // check metadata - assertEquals(server.getMetadata(), metadata); - assertTrue(server.getImageRef().endsWith(String.valueOf(testImageId))); - // listAddresses tests.. - assertEquals(client.getAddresses(server.getId()), server.getAddresses()); - assertEquals(server.getAddresses().getPublicAddresses().size(), 1); - assertEquals(client.listPublicAddresses(server.getId()), server.getAddresses().getPublicAddresses()); - assertEquals(server.getAddresses().getPrivateAddresses().size(), 1); - assertEquals(client.listPrivateAddresses(server.getId()), server.getAddresses().getPrivateAddresses()); - assertPassword(server, server.getAdminPass()); - assertTrue(server.getFlavorRef().endsWith("1")); - assert server.getProgress() >= 0 : "newDetails.getProgress()" + server.getProgress(); - } - - - private void assertPassword(Server server, String pass) throws IOException { - IPSocket socket = new IPSocket(Iterables.get(server.getAddresses().getPublicAddresses(), 0).getAddress(), 22); - //socketTester.apply(socket); - - SshClient client = sshFactory.create(socket, new Credentials("root", keyPair.get("private"))); - try { - client.connect(); - Payload etcPasswd = client.get("/etc/jclouds.txt"); - String etcPasswdContents = Strings2.toStringAndClose(etcPasswd.getInput()); - assertEquals("rackspace", etcPasswdContents.trim()); - } finally { - if (client != null) - client.disconnect(); - } - } - - @Test(enabled = true, timeOut = 5 * 60 * 1000) - public void testRenameServer() throws Exception { - Server server = getDefaultServerImmediately(); - int serverId = server.getId(); - String oldName = server.getName(); - client.renameServer(serverId, oldName + "new"); - blockUntilServerActive(serverId); - assertEquals(oldName + "new", client.getServer(serverId).getName()); - } - - @Test(enabled = true, timeOut = 5 * 60 * 1000) - public void testChangePassword() throws Exception { - int serverId = getDefaultServerImmediately().getId(); - blockUntilServerActive(serverId); - client.changeAdminPass(serverId, "elmo"); - assertPassword(client.getServer(serverId), "elmo"); - - } - - @Test(enabled = true, timeOut = 10 * 600 * 1000) - public void testCreateImage() throws Exception { - Server server = getDefaultServerImmediately(); - Image image = getDefaultImageImmediately(server); - blockUntilImageActive(image.getId()); - assertEquals("hoofie", image.getName()); - assertEquals(image.getServerRef(), ""); - } - - - @Test(enabled = true, timeOut = 10 * 60 * 1000) - public void testRebuildServer() throws Exception { - Server server = getDefaultServerImmediately(); - Image image = getDefaultImageImmediately(server); - client.rebuildServer(server.getId(), new RebuildServerOptions().withImage(String.valueOf(image.getId()))); - blockUntilServerActive(server.getId()); - // issue Web Hosting #119580 createdImageId comes back incorrect after rebuild - assertEquals(image.getURI(), client.getServer(server.getId()).getImageRef()); - } - - @Test(enabled = true, timeOut = 10 * 60 * 1000) - public void testRebootHard() throws Exception { - Server server = getDefaultServerImmediately(); - client.rebootServer(server.getId(), RebootType.HARD); - blockUntilServerActive(server.getId()); - //TODO check - } - - @Test(enabled = true, timeOut = 10 * 60 * 1000) - public void testRebootSoft() throws Exception { - Server server = getDefaultServerImmediately(); - client.rebootServer(server.getId(), RebootType.SOFT); - blockUntilServerActive(server.getId()); - //TODO check - } - - @Test(enabled = false, timeOut = 60000, dependsOnMethods = "testRebootSoft") - public void testRevertResize() throws Exception { - Server server = getDefaultServerImmediately(); - int serverId = server.getId(); - client.resizeServer(serverId, 2); - blockUntilServerVerifyResize(serverId); - client.revertResizeServer(serverId); - blockUntilServerActive(serverId); - assertEquals(1, client.getServer(serverId).getFlavorRef()); - } - - @Test(enabled = false, timeOut = 10 * 60 * 1000) - public void testConfirmResize() throws Exception { - Server server = getDefaultServerImmediately(); - int serverId = server.getId(); - client.resizeServer(serverId, 2); - blockUntilServerVerifyResize(serverId); - client.confirmResizeServer(serverId); - blockUntilServerActive(serverId); - assertEquals(2, client.getServer(serverId).getFlavorRef()); - } - - @Test(enabled = true, timeOut = 60000) - void deleteServer2() throws Exception { - Server server = getDefaultServerImmediately(); - int serverId = server.getId(); - client.deleteServer(serverId); - waitServerDeleted(serverId); - } - - @Test(enabled = true, timeOut = 60000) - void testDeleteImage() throws Exception { - Image image = getDefaultImageImmediately(getDefaultServerImmediately()); - client.deleteImage(image.getId()); - assert client.getImage(image.getId()) == null; - } - - @Test(enabled = true, timeOut = 60000) - void deleteServer1() throws Exception { - Server server = getDefaultServerImmediately(); - int serverId = server.getId(); - client.deleteServer(serverId); - waitServerDeleted(serverId); - } - - @Test - public void testDeleteAllCreatedServers() { - for (Server server : client.listServers()) { - if (server.getName().startsWith(serverPrefix)) { - client.deleteServer(server.getId()); - System.out.println("Deleted server: " + server); - } - } - } - - @AfterTest - void deleteServersOnEnd() { - testDeleteAllCreatedServers(); - } - -} +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ + +package org.jclouds.openstack.nova.live.novaclient; + +import com.google.common.collect.Iterables; +import org.jclouds.domain.Credentials; +import org.jclouds.http.HttpResponseException; +import org.jclouds.io.Payload; +import org.jclouds.net.IPSocket; +import org.jclouds.openstack.nova.domain.*; +import org.jclouds.openstack.nova.options.RebuildServerOptions; +import org.jclouds.ssh.SshClient; +import org.jclouds.util.Strings2; +import org.testng.annotations.AfterTest; +import org.testng.annotations.Test; + +import java.io.IOException; +import java.util.Set; + +import static org.jclouds.openstack.nova.options.ListOptions.Builder.withDetails; +import static org.testng.Assert.*; + +/** + * Tests behavior of {@code NovaClient} + * + * @author Adrian Cole + */ +// disabled [Web Hosting #129069 +@Test(groups = "live", sequential = true) +public class NovaClientLiveTest extends ClientBase { + + + @Test + public void testListServers() throws Exception { + Set response = client.listServers(); + assert null != response; + long initialContainerCount = response.size(); + assertTrue(initialContainerCount >= 0); + } + + @Test + public void testListServersDetail() throws Exception { + Set response = client.listServers(withDetails()); + assert null != response; + long initialContainerCount = response.size(); + assertTrue(initialContainerCount >= 0); + } + + @Test + public void testListImages() throws Exception { + Set response = client.listImages(); + assert null != response; + long imageCount = response.size(); + assertTrue(imageCount >= 1); + for (Image image : response) { + assertTrue(image.getId() >= 0); + assert null != image.getName() : image; + } + + } + + @Test + public void testListImagesDetail() throws Exception { + Set response = client.listImages(withDetails()); + assert null != response; + long imageCount = response.size(); + assertTrue(imageCount >= 0); + for (Image image : response) { + assertTrue(image.getId() >= 1); + assert null != image.getName() : image; + assert null != image.getStatus() : image; + } + } + + @Test + public void testGetImagesDetail() throws Exception { + Set response = client.listImages(withDetails()); + assert null != response; + long imageCount = response.size(); + assertTrue(imageCount >= 0); + for (Image image : response) { + try { + Image newDetails = client.getImage(image.getId()); + assertEquals(image, newDetails); + } catch (HttpResponseException e) {// Ticket #9867 + if (e.getResponse().getStatusCode() != 400) + throw e; + } + } + } + + @Test + public void testGetImageDetailsNotFound() throws Exception { + assert client.getImage(12312987) == null; + } + + @Test + public void testGetServerDetailsNotFound() throws Exception { + assert client.getServer(12312987) == null; + } + + @Test + public void testGetServersDetail() throws Exception { + Set response = client.listServers(withDetails()); + assert null != response; + assertTrue(response.size() >= 0); + for (Server server : response) { + Server newDetails = client.getServer(server.getId()); + System.out.println("===="); + + System.out.println(server); + System.out.println(newDetails); + System.out.println("===="); + } + for (Server server : response) { + Server newDetails = client.getServer(server.getId()); + assertEquals(server, newDetails); + } + } + + @Test + public void testListFlavors() throws Exception { + Set response = client.listFlavors(); + assert null != response; + long flavorCount = response.size(); + assertTrue(flavorCount >= 1); + for (Flavor flavor : response) { + assertTrue(flavor.getId() >= 0); + assert null != flavor.getName() : flavor; + } + + } + + @Test + public void testListFlavorsDetail() throws Exception { + Set response = client.listFlavors(withDetails()); + assert null != response; + long flavorCount = response.size(); + assertTrue(flavorCount >= 0); + for (Flavor flavor : response) { + assertTrue(flavor.getId() >= 1); + assert null != flavor.getName() : flavor; + assert null != flavor.getDisk() : flavor; + assert null != flavor.getRam() : flavor; + } + } + + @Test + public void testGetFlavorsDetail() throws Exception { + Set response = client.listFlavors(withDetails()); + assert null != response; + long flavorCount = response.size(); + assertTrue(flavorCount >= 0); + for (Flavor flavor : response) { + Flavor newDetails = client.getFlavor(flavor.getId()); + assertEquals(flavor, newDetails); + } + } + + @Test + public void testGetFlavorDetailsNotFound() throws Exception { + assert client.getFlavor(12312987) == null; + } + + + @Test(enabled = true) + public void testCreateServer() throws Exception { + Server server = createDefaultServer(serverPrefix + "for_create"); + assertNotNull(server.getAdminPass()); + int serverId = server.getId(); + @SuppressWarnings("unused") + String adminPass = server.getAdminPass(); + blockUntilServerActive(serverId); + blockUntilPublicAddress(serverId); + client.getServer(serverId).getAddresses().getPublicAddresses().iterator().next().getAddress(); + } + + private void blockUntilPublicAddress(int serverId) throws InterruptedException { + while (client.getServer(serverId).getAddresses().getPublicAddresses().isEmpty()) { + System.out.println("Awaiting public address"); + Thread.sleep(1000); + } + } + + private void blockUntilServerActive(int serverId) throws InterruptedException { + Server currentDetails; + for (currentDetails = client.getServer(serverId); currentDetails.getStatus() != ServerStatus.ACTIVE; currentDetails = client + .getServer(serverId)) { + System.out.printf("blocking on status active%n%s%n", currentDetails); + Thread.sleep(5 * 1000); + } + } + + private void blockUntilServerVerifyResize(int serverId) throws InterruptedException { + Server currentDetails; + for (currentDetails = client.getServer(serverId); currentDetails.getStatus() != ServerStatus.VERIFY_RESIZE; currentDetails = client + .getServer(serverId)) { + System.out.printf("blocking on status verify resize%n%s%n", currentDetails); + Thread.sleep(5 * 1000); + } + } + + private void blockUntilImageActive(int createdImageId) throws InterruptedException { + Image currentDetails; + for (currentDetails = client.getImage(createdImageId); currentDetails.getStatus() != ImageStatus.ACTIVE; currentDetails = client + .getImage(createdImageId)) { + System.out.printf("blocking on status active%n%s%n", currentDetails); + Thread.sleep(5 * 1000); + } + } + + @Test(enabled = true, timeOut = 300000) + public void testServerDetails() throws Exception { + Server server = getDefaultServerImmediately(); + assertNotNull(server.getHostId(), "Host id: "); + assertNotNull(server.getAddresses()); + // check metadata + assertEquals(server.getMetadata(), metadata); + assertTrue(server.getImageRef().endsWith(String.valueOf(testImageId))); + // listAddresses tests.. + assertEquals(client.getAddresses(server.getId()), server.getAddresses()); + assertEquals(server.getAddresses().getPublicAddresses().size(), 1); + assertEquals(client.listPublicAddresses(server.getId()), server.getAddresses().getPublicAddresses()); + assertEquals(server.getAddresses().getPrivateAddresses().size(), 1); + assertEquals(client.listPrivateAddresses(server.getId()), server.getAddresses().getPrivateAddresses()); + assertPassword(server, server.getAdminPass()); + assertTrue(server.getFlavorRef().endsWith("1")); + assert server.getProgress() >= 0 : "newDetails.getProgress()" + server.getProgress(); + } + + + private void assertPassword(Server server, String pass) throws IOException { + IPSocket socket = new IPSocket(Iterables.get(server.getAddresses().getPublicAddresses(), 0).getAddress(), 22); + //socketTester.apply(socket); + + SshClient client = sshFactory.create(socket, new Credentials("root", keyPair.get("private"))); + try { + client.connect(); + Payload etcPasswd = client.get("/etc/jclouds.txt"); + String etcPasswdContents = Strings2.toStringAndClose(etcPasswd.getInput()); + assertEquals("rackspace", etcPasswdContents.trim()); + } finally { + if (client != null) + client.disconnect(); + } + } + + @Test(enabled = true, timeOut = 5 * 60 * 1000) + public void testRenameServer() throws Exception { + Server server = getDefaultServerImmediately(); + int serverId = server.getId(); + String oldName = server.getName(); + client.renameServer(serverId, oldName + "new"); + blockUntilServerActive(serverId); + assertEquals(oldName + "new", client.getServer(serverId).getName()); + } + + @Test(enabled = true, timeOut = 5 * 60 * 1000) + public void testChangePassword() throws Exception { + int serverId = getDefaultServerImmediately().getId(); + blockUntilServerActive(serverId); + client.changeAdminPass(serverId, "elmo"); + assertPassword(client.getServer(serverId), "elmo"); + + } + + @Test(enabled = true, timeOut = 10 * 600 * 1000) + public void testCreateImage() throws Exception { + Server server = getDefaultServerImmediately(); + Image image = getDefaultImageImmediately(server); + blockUntilImageActive(image.getId()); + assertEquals("hoofie", image.getName()); + assertEquals(image.getServerRef(), ""); + } + + + @Test(enabled = true, timeOut = 10 * 60 * 1000) + public void testRebuildServer() throws Exception { + Server server = getDefaultServerImmediately(); + Image image = getDefaultImageImmediately(server); + client.rebuildServer(server.getId(), new RebuildServerOptions().withImage(String.valueOf(image.getId()))); + blockUntilServerActive(server.getId()); + // issue Web Hosting #119580 createdImageId comes back incorrect after rebuild + assertEquals(image.getURI(), client.getServer(server.getId()).getImageRef()); + } + + @Test(enabled = true, timeOut = 10 * 60 * 1000) + public void testRebootHard() throws Exception { + Server server = getDefaultServerImmediately(); + client.rebootServer(server.getId(), RebootType.HARD); + blockUntilServerActive(server.getId()); + //TODO check + } + + @Test(enabled = true, timeOut = 10 * 60 * 1000) + public void testRebootSoft() throws Exception { + Server server = getDefaultServerImmediately(); + client.rebootServer(server.getId(), RebootType.SOFT); + blockUntilServerActive(server.getId()); + //TODO check + } + + @Test(enabled = false, timeOut = 60000, dependsOnMethods = "testRebootSoft") + public void testRevertResize() throws Exception { + Server server = getDefaultServerImmediately(); + int serverId = server.getId(); + client.resizeServer(serverId, 2); + blockUntilServerVerifyResize(serverId); + client.revertResizeServer(serverId); + blockUntilServerActive(serverId); + assertEquals(1, client.getServer(serverId).getFlavorRef()); + } + + @Test(enabled = false, timeOut = 10 * 60 * 1000) + public void testConfirmResize() throws Exception { + Server server = getDefaultServerImmediately(); + int serverId = server.getId(); + client.resizeServer(serverId, 2); + blockUntilServerVerifyResize(serverId); + client.confirmResizeServer(serverId); + blockUntilServerActive(serverId); + assertEquals(2, client.getServer(serverId).getFlavorRef()); + } + + @Test(enabled = true, timeOut = 60000) + void deleteServer2() throws Exception { + Server server = getDefaultServerImmediately(); + int serverId = server.getId(); + client.deleteServer(serverId); + waitServerDeleted(serverId); + } + + @Test(enabled = true, timeOut = 60000) + void testDeleteImage() throws Exception { + Image image = getDefaultImageImmediately(getDefaultServerImmediately()); + client.deleteImage(image.getId()); + assert client.getImage(image.getId()) == null; + } + + @Test(enabled = true, timeOut = 60000) + void deleteServer1() throws Exception { + Server server = getDefaultServerImmediately(); + int serverId = server.getId(); + client.deleteServer(serverId); + waitServerDeleted(serverId); + } + + @Test + public void testDeleteAllCreatedServers() { + for (Server server : client.listServers()) { + if (server.getName().startsWith(serverPrefix)) { + client.deleteServer(server.getId()); + System.out.println("Deleted server: " + server); + } + } + } + + @AfterTest + void deleteServersOnEnd() { + testDeleteAllCreatedServers(); + } + +} From 9916285ae723290dc0d7951e7cb51099bdb038c0 Mon Sep 17 00:00:00 2001 From: Dmitri Babaev Date: Thu, 2 Jun 2011 17:05:45 +0400 Subject: [PATCH 012/264] timeout for tests is increased --- .../openstack/nova/live/compute/NovaComputeServiceLiveTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apis/nova/src/test/java/org/jclouds/openstack/nova/live/compute/NovaComputeServiceLiveTest.java b/apis/nova/src/test/java/org/jclouds/openstack/nova/live/compute/NovaComputeServiceLiveTest.java index eea284b089..1e3351bd06 100644 --- a/apis/nova/src/test/java/org/jclouds/openstack/nova/live/compute/NovaComputeServiceLiveTest.java +++ b/apis/nova/src/test/java/org/jclouds/openstack/nova/live/compute/NovaComputeServiceLiveTest.java @@ -144,7 +144,7 @@ public class NovaComputeServiceLiveTest extends ComputeBase { } } - @Test(timeOut = 60000) + @Test(timeOut = 120000) public void testScriptExecutionAfterBootWithBasicTemplate() throws InterruptedException, RunNodesException, RunScriptOnNodesException, URISyntaxException, IOException { NodeMetadata node = getDefaultNodeImmediately(group); From e49e0254ce0f405ca2af0d07f795f14acb00e091 Mon Sep 17 00:00:00 2001 From: Adrian Cole Date: Thu, 2 Jun 2011 11:08:58 -0700 Subject: [PATCH 013/264] Issue 591:Need to handle 2+ cookies from TE --- .../ParseLoginResponseFromHeaders.java | 61 ++++++++++-------- .../ParseLoginResponseFromHeadersTest.java | 63 +++++++++++++++---- 2 files changed, 86 insertions(+), 38 deletions(-) diff --git a/common/vcloud/src/main/java/org/jclouds/vcloud/functions/ParseLoginResponseFromHeaders.java b/common/vcloud/src/main/java/org/jclouds/vcloud/functions/ParseLoginResponseFromHeaders.java index 4453929364..6c71e10d4e 100755 --- a/common/vcloud/src/main/java/org/jclouds/vcloud/functions/ParseLoginResponseFromHeaders.java +++ b/common/vcloud/src/main/java/org/jclouds/vcloud/functions/ParseLoginResponseFromHeaders.java @@ -18,10 +18,10 @@ */ package org.jclouds.vcloud.functions; -import static com.google.common.base.Preconditions.checkNotNull; import static org.jclouds.http.HttpUtils.releasePayload; import java.util.Map; +import java.util.NoSuchElementException; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -41,6 +41,8 @@ import org.jclouds.vcloud.endpoints.Org; import org.jclouds.vcloud.xml.OrgListHandler; import com.google.common.base.Function; +import com.google.common.base.Predicates; +import com.google.common.collect.Iterables; /** * This parses {@link VCloudSession} from HTTP headers. @@ -49,7 +51,7 @@ import com.google.common.base.Function; */ @Singleton public class ParseLoginResponseFromHeaders implements Function { - static final Pattern pattern = Pattern.compile("(vcloud-token=)?([^;]+)(;.*)?"); + static final Pattern pattern = Pattern.compile("(vcloud-token)=?([^;]+)(;.*)?"); private final ParseSax.Factory factory; private final Provider orgHandlerProvider; @@ -61,38 +63,45 @@ public class ParseLoginResponseFromHeaders implements Function org = factory.create(orgHandlerProvider.get()).parse( + final String token = parseTokenFromHeaders(from); + final Map org = factory.create(orgHandlerProvider.get()).parse( from.getPayload().getInput()); - return new VCloudSession() { - @VCloudToken - public String getVCloudToken() { - return matcher.group(2); - } + return new VCloudSession() { + @VCloudToken + public String getVCloudToken() { + return token; + } - @Org - public Map getOrgs() { - return org; - } - }; - - } + @Org + public Map getOrgs() { + return org; + } + }; } finally { releasePayload(from); } - throw new HttpResponseException("x-vcloud-authorization not found ", null, from); + } + + public String parseTokenFromHeaders(HttpResponse from) { + String cookieHeader = from.getFirstHeaderOrNull("x-vcloud-authorization"); + if (cookieHeader != null) { + Matcher matcher = pattern.matcher(cookieHeader); + return matcher.find() ? matcher.group(2) : cookieHeader; + } else { + try { + cookieHeader = Iterables.find(from.getHeaders().get(HttpHeaders.SET_COOKIE), Predicates.contains(pattern)); + Matcher matcher = pattern.matcher(cookieHeader); + matcher.find(); + return matcher.group(2); + } catch (NoSuchElementException e) { + throw new HttpResponseException(String.format("Header %s or %s must be present", "x-vcloud-authorization", + HttpHeaders.SET_COOKIE), null, from); + } + } } } diff --git a/common/vcloud/src/test/java/org/jclouds/vcloud/functions/ParseLoginResponseFromHeadersTest.java b/common/vcloud/src/test/java/org/jclouds/vcloud/functions/ParseLoginResponseFromHeadersTest.java index d4945d37f0..fdfeadc1ea 100644 --- a/common/vcloud/src/test/java/org/jclouds/vcloud/functions/ParseLoginResponseFromHeadersTest.java +++ b/common/vcloud/src/test/java/org/jclouds/vcloud/functions/ParseLoginResponseFromHeadersTest.java @@ -23,6 +23,7 @@ import static org.testng.Assert.assertEquals; import java.net.URI; import org.jclouds.http.HttpResponse; +import org.jclouds.http.HttpResponseException; import org.jclouds.http.functions.BaseHandlerTest; import org.jclouds.io.Payloads; import org.jclouds.vcloud.VCloudMediaType; @@ -54,60 +55,98 @@ public class ParseLoginResponseFromHeadersTest extends BaseHandlerTest { @Test public void testApply() { HttpResponse response = new HttpResponse(200, "OK", Payloads.newInputStreamPayload(getClass() - .getResourceAsStream("/orglist.xml")), ImmutableMultimap. of("x-vcloud-authorization", - "vcloud-token=9er4d061-4bff-48fa-84b1-5da7166764d2; path=/")); + .getResourceAsStream("/orglist.xml")), ImmutableMultimap. of("x-vcloud-authorization", + "vcloud-token=9er4d061-4bff-48fa-84b1-5da7166764d2; path=/")); response.getPayload().getContentMetadata().setContentType("Content-Type: application/xml; charset=utf-8"); response.getPayload().getContentMetadata().setContentLength(307l); VCloudSession reply = parser.apply(response); assertEquals(reply.getVCloudToken(), "9er4d061-4bff-48fa-84b1-5da7166764d2"); assertEquals(reply.getOrgs(), ImmutableMap.of("adrian@jclouds.org", new ReferenceTypeImpl("adrian@jclouds.org", - VCloudMediaType.ORG_XML, URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/org/48")))); + VCloudMediaType.ORG_XML, URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/org/48")))); } @Test public void testApplyBlueLock() { HttpResponse response = new HttpResponse(200, "OK", Payloads.newInputStreamPayload(getClass() - .getResourceAsStream("/orglist.xml")), ImmutableMultimap. of("x-vcloud-authorization", - "MUKOJ2HoAfoMmLnHRp4esNb2MtWscCLLhVysnsIsCG0=")); + .getResourceAsStream("/orglist.xml")), ImmutableMultimap. of("x-vcloud-authorization", + "MUKOJ2HoAfoMmLnHRp4esNb2MtWscCLLhVysnsIsCG0=")); response.getPayload().getContentMetadata().setContentType("Content-Type: application/xml; charset=utf-8"); response.getPayload().getContentMetadata().setContentLength(307l); VCloudSession reply = parser.apply(response); assertEquals(reply.getVCloudToken(), "MUKOJ2HoAfoMmLnHRp4esNb2MtWscCLLhVysnsIsCG0="); assertEquals(reply.getOrgs(), ImmutableMap.of("adrian@jclouds.org", new ReferenceTypeImpl("adrian@jclouds.org", - VCloudMediaType.ORG_XML, URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/org/48")))); + VCloudMediaType.ORG_XML, URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/org/48")))); } @Test public void testApplyTerremark() { HttpResponse response = new HttpResponse(200, "OK", Payloads.newInputStreamPayload(getClass() - .getResourceAsStream("/orglist.xml")), ImmutableMultimap. of("Set-Cookie", - "vcloud-token=37ce2715-9aba-4f48-8e45-2db8a8da702d; path=/")); + .getResourceAsStream("/orglist.xml")), ImmutableMultimap. of("Set-Cookie", + "vcloud-token=37ce2715-9aba-4f48-8e45-2db8a8da702d; path=/")); response.getPayload().getContentMetadata().setContentType("Content-Type: application/xml; charset=utf-8"); response.getPayload().getContentMetadata().setContentLength(307l); VCloudSession reply = parser.apply(response); assertEquals(reply.getVCloudToken(), "37ce2715-9aba-4f48-8e45-2db8a8da702d"); assertEquals(reply.getOrgs(), ImmutableMap.of("adrian@jclouds.org", new ReferenceTypeImpl("adrian@jclouds.org", - VCloudMediaType.ORG_XML, URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/org/48")))); + VCloudMediaType.ORG_XML, URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/org/48")))); } + @Test + public void testApplyTerremarkMultipleCookies() { + HttpResponse response = new HttpResponse(200, "OK", Payloads.newInputStreamPayload(getClass() + .getResourceAsStream("/orglist.xml")), ImmutableMultimap. builder().put("Set-Cookie", + "NSC_ESUO_21654_72.46.239.132_443=fooo;expires=Thu, 02-Jun-2011 17:19:26 GMT;path=/;secure;httponly") + .put("Set-Cookie", "vcloud-token=37ce2715-9aba-4f48-8e45-2db8a8da702d; path=/").build()); + response.getPayload().getContentMetadata().setContentType("Content-Type: application/xml; charset=utf-8"); + response.getPayload().getContentMetadata().setContentLength(307l); + + VCloudSession reply = parser.apply(response); + assertEquals(reply.getVCloudToken(), "37ce2715-9aba-4f48-8e45-2db8a8da702d"); + assertEquals(reply.getOrgs(), ImmutableMap.of("adrian@jclouds.org", new ReferenceTypeImpl("adrian@jclouds.org", + VCloudMediaType.ORG_XML, URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/org/48")))); + + } + + @Test(expectedExceptions = HttpResponseException.class) + public void testUnmatchedCookieThrowsHttpResponseException() { + HttpResponse response = new HttpResponse(200, "OK", Payloads.newInputStreamPayload(getClass() + .getResourceAsStream("/orglist.xml")), ImmutableMultimap. builder().put("Set-Cookie", + "NSC_ESUO_21654_72.46.239.132_443=fooo;expires=Thu, 02-Jun-2011 17:19:26 GMT;path=/;secure;httponly") + .build()); + response.getPayload().getContentMetadata().setContentType("Content-Type: application/xml; charset=utf-8"); + response.getPayload().getContentMetadata().setContentLength(307l); + + parser.apply(response); + } + + @Test(expectedExceptions = HttpResponseException.class) + public void testNoThrowsHttpResponseException() { + HttpResponse response = new HttpResponse(200, "OK", Payloads.newInputStreamPayload(getClass() + .getResourceAsStream("/orglist.xml")), ImmutableMultimap. of()); + response.getPayload().getContentMetadata().setContentType("Content-Type: application/xml; charset=utf-8"); + response.getPayload().getContentMetadata().setContentLength(307l); + + parser.apply(response); + } + @Test public void testApplyVirtacore() { HttpResponse response = new HttpResponse(200, "OK", Payloads.newInputStreamPayload(getClass() - .getResourceAsStream("/orglist.xml")), ImmutableMultimap. of("x-vcloud-authorization", - "vcloud-token=IPy0w7UGD4lwtdWAK/ZVzfuLK+dztxGRqsOhWqV0i48=")); + .getResourceAsStream("/orglist.xml")), ImmutableMultimap. of("x-vcloud-authorization", + "vcloud-token=IPy0w7UGD4lwtdWAK/ZVzfuLK+dztxGRqsOhWqV0i48=")); response.getPayload().getContentMetadata().setContentType("Content-Type: application/xml; charset=utf-8"); response.getPayload().getContentMetadata().setContentLength(307l); VCloudSession reply = parser.apply(response); assertEquals(reply.getVCloudToken(), "IPy0w7UGD4lwtdWAK/ZVzfuLK+dztxGRqsOhWqV0i48="); assertEquals(reply.getOrgs(), ImmutableMap.of("adrian@jclouds.org", new ReferenceTypeImpl("adrian@jclouds.org", - VCloudMediaType.ORG_XML, URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/org/48")))); + VCloudMediaType.ORG_XML, URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/org/48")))); } } From 85fad8e3f7bcb9b1a0b4ff5687b510d16dfcd8d4 Mon Sep 17 00:00:00 2001 From: Kedar Dave Date: Thu, 2 Jun 2011 13:36:23 -0500 Subject: [PATCH 014/264] fixed tests for savvis --- providers/savvis-symphonyvpdc/pom.xml | 1 + .../vpdc/features/FirewallAsyncClient.java | 4 +- .../vpdc/features/BaseVPDCClientLiveTest.java | 4 + .../vpdc/features/BrowsingClientLiveTest.java | 6 +- .../vpdc/features/FirewallClientLiveTest.java | 22 ++- .../vpdc/features/VMClientLiveTest.java | 167 ++++++------------ 6 files changed, 83 insertions(+), 121 deletions(-) diff --git a/providers/savvis-symphonyvpdc/pom.xml b/providers/savvis-symphonyvpdc/pom.xml index 0c19c904d2..529e9e254f 100644 --- a/providers/savvis-symphonyvpdc/pom.xml +++ b/providers/savvis-symphonyvpdc/pom.xml @@ -126,6 +126,7 @@ test + 1 test.savvis-symphonyvpdc.endpoint diff --git a/providers/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/features/FirewallAsyncClient.java b/providers/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/features/FirewallAsyncClient.java index ee44b53e55..076b1a1c22 100644 --- a/providers/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/features/FirewallAsyncClient.java +++ b/providers/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/features/FirewallAsyncClient.java @@ -55,7 +55,7 @@ public interface FirewallAsyncClient { */ @PUT @XMLResponseParser(TaskHandler.class) - @Path("v{jclouds.api-version}/org/{billingSiteId}/vdc/{vpdcId}/FirewallService/") + @Path("v{jclouds.api-version}/org/{billingSiteId}/vdc/{vpdcId}/FirewallService") @MapBinder(BindFirewallRuleToXmlPayload.class) ListenableFuture addFirewallRule( @PathParam("billingSiteId") @Nullable @ParamParser(DefaultOrgIfNull.class) String billingSiteId, @@ -66,7 +66,7 @@ public interface FirewallAsyncClient { */ @DELETE @XMLResponseParser(TaskHandler.class) - @Path("v{jclouds.api-version}/org/{billingSiteId}/vdc/{vpdcId}/FirewallService/") + @Path("v{jclouds.api-version}/org/{billingSiteId}/vdc/{vpdcId}/FirewallService") @MapBinder(BindFirewallRuleToXmlPayload.class) @ExceptionParser(ReturnNullOnNotFoundOr404.class) ListenableFuture deleteFirewallRule( diff --git a/providers/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/features/BaseVPDCClientLiveTest.java b/providers/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/features/BaseVPDCClientLiveTest.java index 0080de9373..12e30f4951 100644 --- a/providers/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/features/BaseVPDCClientLiveTest.java +++ b/providers/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/features/BaseVPDCClientLiveTest.java @@ -24,6 +24,7 @@ import static com.google.common.base.Preconditions.checkNotNull; import java.util.Properties; import java.util.concurrent.TimeUnit; +import org.jclouds.Constants; import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.ComputeServiceContextFactory; import org.jclouds.logging.log4j.config.Log4JLoggingModule; @@ -79,6 +80,9 @@ public class BaseVPDCClientLiveTest { overrides.setProperty(provider + ".endpoint", endpoint); if (apiversion != null) overrides.setProperty(provider + ".apiversion", apiversion); + // TODO savvis uses untrusted certificates, remove these once savvis fixes the issue + overrides.setProperty(Constants.PROPERTY_TRUST_ALL_CERTS, "true"); + overrides.setProperty(Constants.PROPERTY_RELAX_HOSTNAME, "true"); return overrides; } diff --git a/providers/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/features/BrowsingClientLiveTest.java b/providers/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/features/BrowsingClientLiveTest.java index 473f6e6380..738400a5cb 100644 --- a/providers/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/features/BrowsingClientLiveTest.java +++ b/providers/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/features/BrowsingClientLiveTest.java @@ -151,9 +151,13 @@ public class BrowsingClientLiveTest extends BaseVPDCClientLiveTest { String ip = Iterables.get(response.getNetworkConnectionSections(), 0).getIpAddress(); assert HostSpecifier.isValid(ip) : response; if (InetAddresses2.isPrivateIPAddress(ip)) { + // get public ip ip = Iterables.get(response.getNetworkConfigSections(), 0).getInternalToExternalNATRules().get(ip); + // could be null + if(ip != null){ + assert HostSpecifier.isValid(ip) : response; + } } - assert HostSpecifier.isValid(ip) : response; } } diff --git a/providers/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/features/FirewallClientLiveTest.java b/providers/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/features/FirewallClientLiveTest.java index 14bb39307e..3cf78c641a 100644 --- a/providers/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/features/FirewallClientLiveTest.java +++ b/providers/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/features/FirewallClientLiveTest.java @@ -52,9 +52,14 @@ public class FirewallClientLiveTest extends BaseVPDCClientLiveTest { // the jclouds-wire.log @Override public boolean apply(Resource arg0) { - String description = restContext.getApi().getBrowsingClient().getVDCInOrg(billingSiteId, + if(restContext.getApi().getBrowsingClient().getVDCInOrg(billingSiteId, + arg0.getId()).getName().equals("Oracle")){ + return true; + } + return false; + /*String description = restContext.getApi().getBrowsingClient().getVDCInOrg(billingSiteId, arg0.getId()).getDescription(); - return description.indexOf(email) != -1; + return description.indexOf(email) != -1;*/ } }).getId(); @@ -66,7 +71,7 @@ public class FirewallClientLiveTest extends BaseVPDCClientLiveTest { FirewallRule firewallRule = FirewallRule.builder().firewallType("SERVER_TIER_FIREWALL").isEnabled(true).source("internet") .destination(networkTierName).port("10000").protocol("Tcp").policy("allow").description("Server Tier Firewall Rule").isLogged(false).build(); - System.out.printf("adding firewall rule:%s %n", firewallRule.toString()); + System.out.printf("adding firewall rule:%s in vpdc %s %n", firewallRule.toString(), vpdcId); Task task = client.addFirewallRule(billingSiteId, vpdcId, firewallRule); @@ -87,9 +92,14 @@ public class FirewallClientLiveTest extends BaseVPDCClientLiveTest { // the jclouds-wire.log @Override public boolean apply(Resource arg0) { - String description = restContext.getApi().getBrowsingClient().getVDCInOrg(billingSiteId, + if(restContext.getApi().getBrowsingClient().getVDCInOrg(billingSiteId, + arg0.getId()).getName().equals("Oracle")){ + return true; + } + return false; + /*String description = restContext.getApi().getBrowsingClient().getVDCInOrg(billingSiteId, arg0.getId()).getDescription(); - return description.indexOf(email) != -1; + return description.indexOf(email) != -1;*/ } }).getId(); @@ -101,7 +111,7 @@ public class FirewallClientLiveTest extends BaseVPDCClientLiveTest { FirewallRule firewallRule = FirewallRule.builder().firewallType("SERVER_TIER_FIREWALL").isEnabled(true).source("internet") .destination(networkTierName).port("10000").protocol("Tcp").policy("allow").description("Server Tier Firewall Rule").isLogged(false).build(); - System.out.printf("deleting firewall rule:%s %n", firewallRule.toString()); + System.out.printf("deleting firewall rule:%s in vpdc %s %n", firewallRule.toString(), vpdcId); Task task = client.deleteFirewallRule(billingSiteId, vpdcId, firewallRule); diff --git a/providers/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/features/VMClientLiveTest.java b/providers/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/features/VMClientLiveTest.java index 1a6bc1eb18..ecbf493449 100644 --- a/providers/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/features/VMClientLiveTest.java +++ b/providers/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/features/VMClientLiveTest.java @@ -21,10 +21,11 @@ package org.jclouds.savvis.vpdc.features; import static com.google.common.base.Preconditions.checkNotNull; import static org.testng.Assert.assertEquals; -import java.net.URI; +import java.util.Properties; import java.util.Set; import java.util.concurrent.TimeUnit; +import org.jclouds.Constants; import org.jclouds.cim.OSType; import org.jclouds.compute.domain.CIMOperatingSystem; import org.jclouds.compute.domain.ExecResponse; @@ -38,7 +39,6 @@ import org.jclouds.savvis.vpdc.domain.Task; import org.jclouds.savvis.vpdc.domain.VDC; import org.jclouds.savvis.vpdc.domain.VM; import org.jclouds.savvis.vpdc.domain.VMSpec; -import org.jclouds.savvis.vpdc.domain.VM.Status; import org.jclouds.savvis.vpdc.options.GetVMOptions; import org.jclouds.savvis.vpdc.reference.VCloudMediaType; import org.jclouds.ssh.SshClient; @@ -49,8 +49,8 @@ import org.testng.annotations.Test; import com.google.common.base.Predicate; import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Iterables; import com.google.common.collect.ImmutableSet.Builder; +import com.google.common.collect.Iterables; import com.google.common.net.HostSpecifier; @Test(groups = "live") @@ -98,13 +98,8 @@ public class VMClientLiveTest extends BaseVPDCClientLiveTest { .getName(); String name = prefix; - // delete any old VM VDC vpdc = restContext.getApi().getBrowsingClient().getVDCInOrg(billingSiteId, vpdcId); - for (Resource resource : vpdc.getResourceEntities()) { - if (resource.getName().equals(prefix)) { - taskTester.apply(client.removeVMFromVDC(billingSiteId, vpdcId, resource.getId()).getId()); - } - } + CIMOperatingSystem os = Iterables.find(restContext.getApi().listPredefinedOperatingSystems(), new Predicate() { @@ -114,22 +109,30 @@ public class VMClientLiveTest extends BaseVPDCClientLiveTest { } }); - System.out.printf("vpdcId %s, networkName %s, name %s, os %s%n", vpdcId, networkTierName, name, os); + System.out.printf("Creating vm - vpdcId %s, vpdcName %s, networkName %s, name %s, os %s%n", vpdcId, vpdc.getName(), networkTierName, name, os); // TODO: determine the sizes available in the VDC, for example there's // a minimum size of boot disk, and also a preset combination of cpu count vs ram Task task = client.addVMIntoVDC(billingSiteId, vpdcId, VMSpec.builder().name(name).networkTierName( networkTierName).operatingSystem(os).memoryInGig(2).addDataDrive("/data01", 25).build()); - + // make sure there's no error assert task.getId() != null && task.getError() == null : task; assert this.taskTester.apply(task.getId()); - vm = restContext.getApi().getBrowsingClient().getVMInVDC(billingSiteId, vpdcId, task.getOwner().getId()); - conditionallyCheckSSH(); + + // fetch the task again, in savvis, task.getOwner is populated with vApp after task has finished + task = restContext.getApi().getBrowsingClient().getTask(task.getId()); + + vm = restContext.getApi().getBrowsingClient().getVM(task.getOwner().getHref(), GetVMOptions.NONE); + assert vm.getHref() != null : vm; + + // cannot ssh in savvis, as no public ip is assigned by default +// conditionallyCheckSSH(); } - public void testCreateMultipleVMs() throws Exception { + @Test + public void testZCreateMultipleVMs() throws Exception { billingSiteId = restContext.getApi().getBrowsingClient().getOrg(null).getId();// default vpdcId = Iterables.find(restContext.getApi().getBrowsingClient().getOrg(billingSiteId).getVDCs(), new Predicate() { @@ -168,7 +171,7 @@ public class VMClientLiveTest extends BaseVPDCClientLiveTest { // TODO: Savvis returns network names with a - instead of space on getNetworkInVDC call, // fix this once savvis api starts returning correctly - System.out.printf("vpdcId %s, vpdcName %s, networkName %s, name %s, os %s%n", vpdcId, vpdc.getName(), networkTier + System.out.printf("Creating vm's - vpdcId %s, vpdcName %s, networkName %s, name %s, os %s%n", vpdcId, vpdc.getName(), networkTier .getName().replace("-", " "), name, os); Builder vmSpecs = ImmutableSet. builder(); @@ -186,11 +189,21 @@ public class VMClientLiveTest extends BaseVPDCClientLiveTest { for (Task task : tasks) { // make sure there's no error assert task.getId() != null && task.getError() == null : task; - assert this.taskTester.apply(task.getId()); + + // fetch the task again, in savvis, task.getOwner is populated with vApp after task has finished + task = restContext.getApi().getBrowsingClient().getTask(task.getId()); + + vm = restContext.getApi().getBrowsingClient().getVM(task.getOwner().getHref(), GetVMOptions.NONE); + assert vm.getHref() != null : vm; } } - + + /** + * disabled because it not currently supported by savvis. Planned for august release by savvis. + * @throws Exception + */ + @Test(enabled=false) public void testCaptureVAppTemplate() throws Exception { billingSiteId = restContext.getApi().getBrowsingClient().getOrg(null).getId();// default vpdcId = Iterables.find(restContext.getApi().getBrowsingClient().getOrg(billingSiteId).getVDCs(), @@ -229,9 +242,10 @@ public class VMClientLiveTest extends BaseVPDCClientLiveTest { } } + @Test(dependsOnMethods="testPowerOnVM") public void testCloneVApp() throws Exception { - billingSiteId = restContext.getApi().getBrowsingClient().getOrg(null).getId();// default - vpdcId = Iterables.find(restContext.getApi().getBrowsingClient().getOrg(billingSiteId).getVDCs(), + billingSiteId = restContext.getApi().getBrowsingClient().getOrg(null).getId();// default + vpdcId = Iterables.find(restContext.getApi().getBrowsingClient().getOrg(billingSiteId).getVDCs(), new Predicate() { // try to find the first VDC owned by the current user @@ -245,29 +259,22 @@ public class VMClientLiveTest extends BaseVPDCClientLiveTest { } }).getId(); - - VDC vpdc = restContext.getApi().getBrowsingClient().getVDCInOrg(billingSiteId, vpdcId); - - String networkTierName = Iterables.get(vpdc.getAvailableNetworks(), 0).getId(); - - for (Resource vApp : Iterables.filter(vpdc.getResourceEntities(), new Predicate() { - - @Override - public boolean apply(Resource arg0) { - return VCloudMediaType.VAPP_XML.equals(arg0.getType()); - } - - })) { - - System.out.printf("Cloning VApp - %s%n", vApp.getName()); - - Task task = client.cloneVApp(vApp.getHref(), "clonedvm", networkTierName); - - // make sure there's no error - assert task.getId() != null && task.getError() == null : task; - - assert this.taskTester.apply(task.getId()); - } + + String networkTierName = Iterables.get( + restContext.getApi().getBrowsingClient().getVDCInOrg(billingSiteId, vpdcId).getAvailableNetworks(), 0) + .getId(); + + Task task = client.cloneVApp(vm.getHref(), "clonedvm", networkTierName); + + // make sure there's no error + assert task.getId() != null && task.getError() == null : task; + assert this.taskTester.apply(task.getId()); + + // fetch the task again, in savvis, task.getOwner is populated with vApp after task has finished + task = restContext.getApi().getBrowsingClient().getTask(task.getId()); + + vm = restContext.getApi().getBrowsingClient().getVM(task.getOwner().getHref(), GetVMOptions.NONE); + assert vm.getHref() != null : vm; } private void conditionallyCheckSSH() { @@ -297,84 +304,20 @@ public class VMClientLiveTest extends BaseVPDCClientLiveTest { } } - @Test(enabled = false) + @Test(dependsOnMethods="testCreateVirtualMachine") public void testPowerOffVM() throws Exception { - billingSiteId = restContext.getApi().getBrowsingClient().getOrg(null).getId();// default - vpdcId = Iterables.find(restContext.getApi().getBrowsingClient().getOrg(billingSiteId).getVDCs(), - new Predicate() { - - // try to find the first VDC owned by the current user - // check here for what the email property might be, or in - // the jclouds-wire.log - @Override - public boolean apply(Resource arg0) { - String description = restContext.getApi().getBrowsingClient().getVDCInOrg(billingSiteId, - arg0.getId()).getDescription(); - return description.indexOf(email) != -1; - } - - }).getId(); - - VDC vpdc = restContext.getApi().getBrowsingClient().getVDCInOrg(billingSiteId, vpdcId); - URI vmURI = Iterables.find(vpdc.getResourceEntities(), new Predicate() { - @Override - public boolean apply(Resource arg0) { - if (VCloudMediaType.VAPP_XML.equals(arg0.getType())) { - VM response1 = restContext.getApi().getBrowsingClient().getVM(arg0.getHref(), (GetVMOptions[]) null); - System.out.printf("powering off vm - %s%n", response1.getName()); - if (response1.getStatus().equals(Status.ON)) { - return true; - } - } - return false; - } - - }).getHref(); - - Task task = client.powerOffVM(vmURI); - + Task task = client.powerOffVM(vm.getHref()); + // make sure there's no error assert task.getId() != null && task.getError() == null : task; assert this.taskTester.apply(task.getId()); } - @Test(enabled = false) + @Test(dependsOnMethods="testPowerOffVM") public void testPowerOnVM() throws Exception { - billingSiteId = restContext.getApi().getBrowsingClient().getOrg(null).getId();// default - vpdcId = Iterables.find(restContext.getApi().getBrowsingClient().getOrg(billingSiteId).getVDCs(), - new Predicate() { - - // try to find the first VDC owned by the current user - // check here for what the email property might be, or in - // the jclouds-wire.log - @Override - public boolean apply(Resource arg0) { - String description = restContext.getApi().getBrowsingClient().getVDCInOrg(billingSiteId, - arg0.getId()).getDescription(); - return description.indexOf(email) != -1; - } - - }).getId(); - - VDC vpdc = restContext.getApi().getBrowsingClient().getVDCInOrg(billingSiteId, vpdcId); - URI vmURI = Iterables.find(vpdc.getResourceEntities(), new Predicate() { - @Override - public boolean apply(Resource arg0) { - if (VCloudMediaType.VAPP_XML.equals(arg0.getType())) { - VM response1 = restContext.getApi().getBrowsingClient().getVM(arg0.getHref(), (GetVMOptions[]) null); - System.out.printf("powering on vm - %s%n", response1.getName()); - if (response1.getStatus().equals(Status.OFF)) { - return true; - } - } - return false; - } - - }).getHref(); - - Task task = client.powerOnVM(vmURI); - + Task task = client.powerOnVM(vm.getHref()); + // make sure there's no error assert task.getId() != null && task.getError() == null : task; From 607051a0ca3b1d2fcb18c6bc2fbed9ad6212a349 Mon Sep 17 00:00:00 2001 From: Kedar Dave Date: Thu, 2 Jun 2011 13:41:50 -0500 Subject: [PATCH 015/264] cleanup --- .../vpdc/features/FirewallClientLiveTest.java | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/providers/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/features/FirewallClientLiveTest.java b/providers/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/features/FirewallClientLiveTest.java index 3cf78c641a..6d04042f26 100644 --- a/providers/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/features/FirewallClientLiveTest.java +++ b/providers/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/features/FirewallClientLiveTest.java @@ -52,14 +52,9 @@ public class FirewallClientLiveTest extends BaseVPDCClientLiveTest { // the jclouds-wire.log @Override public boolean apply(Resource arg0) { - if(restContext.getApi().getBrowsingClient().getVDCInOrg(billingSiteId, - arg0.getId()).getName().equals("Oracle")){ - return true; - } - return false; - /*String description = restContext.getApi().getBrowsingClient().getVDCInOrg(billingSiteId, + String description = restContext.getApi().getBrowsingClient().getVDCInOrg(billingSiteId, arg0.getId()).getDescription(); - return description.indexOf(email) != -1;*/ + return description.indexOf(email) != -1; } }).getId(); @@ -92,14 +87,9 @@ public class FirewallClientLiveTest extends BaseVPDCClientLiveTest { // the jclouds-wire.log @Override public boolean apply(Resource arg0) { - if(restContext.getApi().getBrowsingClient().getVDCInOrg(billingSiteId, - arg0.getId()).getName().equals("Oracle")){ - return true; - } - return false; - /*String description = restContext.getApi().getBrowsingClient().getVDCInOrg(billingSiteId, + String description = restContext.getApi().getBrowsingClient().getVDCInOrg(billingSiteId, arg0.getId()).getDescription(); - return description.indexOf(email) != -1;*/ + return description.indexOf(email) != -1; } }).getId(); From 006d5e0eed397444683d867a7a0da63a4386cbbe Mon Sep 17 00:00:00 2001 From: Dmitri Babaev Date: Thu, 2 Jun 2011 23:21:14 +0400 Subject: [PATCH 016/264] more fixes in live tests more debug logging --- .../nova/live/compute/NovaComputeServiceLiveTest.java | 3 ++- .../openstack/nova/live/compute/ServiceActionsLiveTest.java | 2 +- apis/nova/src/test/resources/logback.xml | 3 +++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/apis/nova/src/test/java/org/jclouds/openstack/nova/live/compute/NovaComputeServiceLiveTest.java b/apis/nova/src/test/java/org/jclouds/openstack/nova/live/compute/NovaComputeServiceLiveTest.java index 1e3351bd06..8e59615bba 100644 --- a/apis/nova/src/test/java/org/jclouds/openstack/nova/live/compute/NovaComputeServiceLiveTest.java +++ b/apis/nova/src/test/java/org/jclouds/openstack/nova/live/compute/NovaComputeServiceLiveTest.java @@ -159,7 +159,8 @@ public class NovaComputeServiceLiveTest extends ComputeBase { //TODO runJavaInstallationScriptWithCreds(group, os, new Credentials("root", keyPair.get("private"))); //TODO no response? if os is null (ZYPPER) - checkNodes(Sets.newHashSet(node), group); + node = computeService.getNodeMetadata(node.getId()); + checkNodes(Sets.newHashSet(node), group); @SuppressWarnings("unused") Credentials good = node.getCredentials(); diff --git a/apis/nova/src/test/java/org/jclouds/openstack/nova/live/compute/ServiceActionsLiveTest.java b/apis/nova/src/test/java/org/jclouds/openstack/nova/live/compute/ServiceActionsLiveTest.java index 7e9f7f8417..f45e189121 100644 --- a/apis/nova/src/test/java/org/jclouds/openstack/nova/live/compute/ServiceActionsLiveTest.java +++ b/apis/nova/src/test/java/org/jclouds/openstack/nova/live/compute/ServiceActionsLiveTest.java @@ -56,7 +56,7 @@ public class ServiceActionsLiveTest extends ComputeBase { //testGetNodeMetadata(); } - @Test + @Test //Suspend is not supported by the provider yet public void testSuspendResume() throws Exception { getDefaultNodeImmediately(group); computeService.suspendNodesMatching(inGroup(group)); diff --git a/apis/nova/src/test/resources/logback.xml b/apis/nova/src/test/resources/logback.xml index 5c9c501b0c..b64d307f25 100644 --- a/apis/nova/src/test/resources/logback.xml +++ b/apis/nova/src/test/resources/logback.xml @@ -12,4 +12,7 @@ + + + \ No newline at end of file From 34bbfa3797d68e83bec5962c86cc70f2fe8f9b4f Mon Sep 17 00:00:00 2001 From: Adrian Cole Date: Thu, 2 Jun 2011 12:59:57 -0700 Subject: [PATCH 017/264] more detail on test failures in elasticstack --- .../org/jclouds/elasticstack/ElasticStackClientLiveTest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apis/elasticstack/src/test/java/org/jclouds/elasticstack/ElasticStackClientLiveTest.java b/apis/elasticstack/src/test/java/org/jclouds/elasticstack/ElasticStackClientLiveTest.java index 05993b1d4e..b6085157e0 100644 --- a/apis/elasticstack/src/test/java/org/jclouds/elasticstack/ElasticStackClientLiveTest.java +++ b/apis/elasticstack/src/test/java/org/jclouds/elasticstack/ElasticStackClientLiveTest.java @@ -159,8 +159,8 @@ public class ElasticStackClientLiveTest { @Test public void testGetDrive() throws Exception { for (String driveUUID : client.listDrives()) { - assert !"".equals(driveUUID); - assertNotNull(client.getDriveInfo(driveUUID)); + assert !"".equals(driveUUID) : driveUUID; + assert client.getDriveInfo(driveUUID) != null : driveUUID; } } From 11884540a65d9cccb36f9799a7a3d7f01296312a Mon Sep 17 00:00:00 2001 From: Adrian Cole Date: Thu, 2 Jun 2011 13:00:18 -0700 Subject: [PATCH 018/264] test size comparison when testing templates --- .../compute/BaseTemplateBuilderLiveTest.java | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/compute/src/test/java/org/jclouds/compute/BaseTemplateBuilderLiveTest.java b/compute/src/test/java/org/jclouds/compute/BaseTemplateBuilderLiveTest.java index cc30beefcd..5ae857f58a 100644 --- a/compute/src/test/java/org/jclouds/compute/BaseTemplateBuilderLiveTest.java +++ b/compute/src/test/java/org/jclouds/compute/BaseTemplateBuilderLiveTest.java @@ -33,6 +33,7 @@ import java.util.concurrent.TimeoutException; import org.jclouds.Constants; import org.jclouds.compute.config.BaseComputeServiceContextModule; +import org.jclouds.compute.domain.Hardware; import org.jclouds.compute.domain.OsFamily; import org.jclouds.compute.domain.OsFamilyVersion64Bit; import org.jclouds.compute.domain.Template; @@ -77,6 +78,29 @@ public abstract class BaseTemplateBuilderLiveTest { apiversion = System.getProperty("test." + provider + ".apiversion"); } + public void testCompareSizes() throws Exception { + Hardware defaultSize = context.getComputeService().templateBuilder().build().getHardware(); + + Hardware smallest = context.getComputeService().templateBuilder().smallest().build().getHardware(); + Hardware fastest = context.getComputeService().templateBuilder().fastest().build().getHardware(); + Hardware biggest = context.getComputeService().templateBuilder().biggest().build().getHardware(); + + System.out.printf("smallest %s%n", smallest); + System.out.printf("fastest %s%n", fastest); + System.out.printf("biggest %s%n", biggest); + + assertEquals(defaultSize, smallest); + + assert getCores(smallest) <= getCores(fastest) : String.format("%s ! <= %s", smallest, fastest); + assert getCores(biggest) <= getCores(fastest) : String.format("%s ! <= %s", biggest, fastest); + + assert biggest.getRam() >= fastest.getRam() : String.format("%s ! >= %s", biggest, fastest); + assert biggest.getRam() >= smallest.getRam() : String.format("%s ! >= %s", biggest, smallest); + + assert getCores(fastest) >= getCores(biggest) : String.format("%s ! >= %s", fastest, biggest); + assert getCores(fastest) >= getCores(smallest) : String.format("%s ! >= %s", fastest, smallest); + } + protected Properties setupProperties() { Properties overrides = new Properties(); overrides.setProperty(Constants.PROPERTY_TRUST_ALL_CERTS, "true"); From eef22241f46d8592fb1418de16a3cd591076dc24 Mon Sep 17 00:00:00 2001 From: Kedar Dave Date: Thu, 2 Jun 2011 15:15:23 -0500 Subject: [PATCH 019/264] fixed firewallservice url --- .../jclouds/savvis/vpdc/features/FirewallAsyncClientTest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/providers/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/features/FirewallAsyncClientTest.java b/providers/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/features/FirewallAsyncClientTest.java index 9d15ec78e2..b533f708e1 100644 --- a/providers/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/features/FirewallAsyncClientTest.java +++ b/providers/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/features/FirewallAsyncClientTest.java @@ -48,7 +48,7 @@ public class FirewallAsyncClientTest extends BaseVPDCAsyncClientTest Date: Thu, 2 Jun 2011 13:19:39 -0700 Subject: [PATCH 020/264] bumped aws-ec2 to 11.04 ubuntu --- .../jclouds/aws/ec2/compute/AWSEC2TemplateBuilderLiveTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/compute/AWSEC2TemplateBuilderLiveTest.java b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/compute/AWSEC2TemplateBuilderLiveTest.java index ed15d0962a..57126d25fe 100644 --- a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/compute/AWSEC2TemplateBuilderLiveTest.java +++ b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/compute/AWSEC2TemplateBuilderLiveTest.java @@ -84,7 +84,7 @@ public class AWSEC2TemplateBuilderLiveTest extends BaseTemplateBuilderLiveTest { .osVersionMatches("1[10].[10][04]").imageDescriptionMatches("ubuntu-images").osFamily(OsFamily.UBUNTU).build(); assert (template.getImage().getProviderId().startsWith("ami-")) : template; - assertEquals(template.getImage().getOperatingSystem().getVersion(), "10.10"); + assertEquals(template.getImage().getOperatingSystem().getVersion(), "11.04"); assertEquals(template.getImage().getOperatingSystem().is64Bit(), false); assertEquals(template.getImage().getOperatingSystem().getFamily(), OsFamily.UBUNTU); assertEquals(template.getImage().getUserMetadata().get("rootDeviceType"), "instance-store"); From a0692e737ff9c83ecdfb38149b55b3b55b61a572 Mon Sep 17 00:00:00 2001 From: Adrian Cole Date: Thu, 2 Jun 2011 13:20:17 -0700 Subject: [PATCH 021/264] refactored so that eucalyptus m1.small can use 64 bit image --- .../ec2/compute/domain/EC2HardwareBuilder.java | 14 ++++++++++++-- .../ec2/compute/suppliers/EC2HardwareSupplier.java | 3 +-- .../ec2/compute/EC2TemplateBuilderTest.java | 4 ++-- .../RunningInstanceToNodeMetadataTest.java | 10 +++++----- ...urityGroupsAsNeededAndReturnRunOptionsTest.java | 4 ++-- .../compute/suppliers/AWSEC2HardwareSupplier.java | 4 ++-- ...urityGroupsAsNeededAndReturnRunOptionsTest.java | 6 +++--- ...tnerCloudEucalyptusTemplateBuilderLiveTest.java | 11 ++++++++--- 8 files changed, 35 insertions(+), 21 deletions(-) diff --git a/apis/ec2/src/main/java/org/jclouds/ec2/compute/domain/EC2HardwareBuilder.java b/apis/ec2/src/main/java/org/jclouds/ec2/compute/domain/EC2HardwareBuilder.java index 53cbe925d8..2e10e9f7cc 100644 --- a/apis/ec2/src/main/java/org/jclouds/ec2/compute/domain/EC2HardwareBuilder.java +++ b/apis/ec2/src/main/java/org/jclouds/ec2/compute/domain/EC2HardwareBuilder.java @@ -209,13 +209,23 @@ public class EC2HardwareBuilder extends HardwareBuilder { /** * @see InstanceType#M1_SMALL */ - public static EC2HardwareBuilder m1_small() { + public static EC2HardwareBuilder m1_small32() { return new EC2HardwareBuilder(InstanceType.M1_SMALL).ram(1740).processors( ImmutableList.of(new Processor(1.0, 1.0))).volumes( ImmutableList. of(new VolumeImpl(10.0f, "/dev/sda1", true, false), new VolumeImpl(150.0f, "/dev/sda2", false, false))).is64Bit(false); } - + + /** + * @see InstanceType#M1_SMALL + */ + public static EC2HardwareBuilder m1_small() { + return new EC2HardwareBuilder(InstanceType.M1_SMALL).ram(1740).processors( + ImmutableList.of(new Processor(1.0, 1.0))).volumes( + ImmutableList. of(new VolumeImpl(10.0f, "/dev/sda1", true, false), new VolumeImpl(150.0f, + "/dev/sda2", false, false))); + } + /** * @see InstanceType#T1_MICRO */ diff --git a/apis/ec2/src/main/java/org/jclouds/ec2/compute/suppliers/EC2HardwareSupplier.java b/apis/ec2/src/main/java/org/jclouds/ec2/compute/suppliers/EC2HardwareSupplier.java index ee0185d107..bcc5d09fa2 100644 --- a/apis/ec2/src/main/java/org/jclouds/ec2/compute/suppliers/EC2HardwareSupplier.java +++ b/apis/ec2/src/main/java/org/jclouds/ec2/compute/suppliers/EC2HardwareSupplier.java @@ -18,7 +18,6 @@ */ package org.jclouds.ec2.compute.suppliers; -import static org.jclouds.compute.predicates.ImagePredicates.any; import static org.jclouds.ec2.compute.domain.EC2HardwareBuilder.c1_medium; import static org.jclouds.ec2.compute.domain.EC2HardwareBuilder.c1_xlarge; import static org.jclouds.ec2.compute.domain.EC2HardwareBuilder.m1_large; @@ -43,7 +42,7 @@ public class EC2HardwareSupplier implements Supplier> { @Override public Set get() { - return ImmutableSet. of(m1_small().supportsImage(any()).build(), c1_medium().build(), c1_xlarge() + return ImmutableSet. of(m1_small().build(), c1_medium().build(), c1_xlarge() .build(), m1_large().build(), m1_xlarge().build()); } } diff --git a/apis/ec2/src/test/java/org/jclouds/ec2/compute/EC2TemplateBuilderTest.java b/apis/ec2/src/test/java/org/jclouds/ec2/compute/EC2TemplateBuilderTest.java index 92d0e9191f..d4bb385fc9 100644 --- a/apis/ec2/src/test/java/org/jclouds/ec2/compute/EC2TemplateBuilderTest.java +++ b/apis/ec2/src/test/java/org/jclouds/ec2/compute/EC2TemplateBuilderTest.java @@ -26,7 +26,7 @@ import static org.jclouds.ec2.compute.domain.EC2HardwareBuilder.c1_medium; import static org.jclouds.ec2.compute.domain.EC2HardwareBuilder.c1_xlarge; import static org.jclouds.ec2.compute.domain.EC2HardwareBuilder.cc1_4xlarge; import static org.jclouds.ec2.compute.domain.EC2HardwareBuilder.m1_large; -import static org.jclouds.ec2.compute.domain.EC2HardwareBuilder.m1_small; +import static org.jclouds.ec2.compute.domain.EC2HardwareBuilder.m1_small32; import static org.jclouds.ec2.compute.domain.EC2HardwareBuilder.m1_xlarge; import static org.jclouds.ec2.compute.domain.EC2HardwareBuilder.m2_2xlarge; import static org.jclouds.ec2.compute.domain.EC2HardwareBuilder.m2_4xlarge; @@ -161,7 +161,7 @@ public class EC2TemplateBuilderTest { .build())); Supplier> sizes = Suppliers.> ofInstance(ImmutableSet . of(t1_micro().build(), c1_medium().build(), c1_xlarge().build(), m1_large().build(), - m1_small().build(), m1_xlarge().build(), m2_xlarge().build(), m2_2xlarge().build(), + m1_small32().build(), m1_xlarge().build(), m2_xlarge().build(), m2_2xlarge().build(), m2_4xlarge().build(), CC1_4XLARGE)); return new TemplateBuilderImpl(locations, images, sizes, Suppliers.ofInstance(location), optionsProvider, diff --git a/apis/ec2/src/test/java/org/jclouds/ec2/compute/functions/RunningInstanceToNodeMetadataTest.java b/apis/ec2/src/test/java/org/jclouds/ec2/compute/functions/RunningInstanceToNodeMetadataTest.java index 4eaca6bf6b..16683b37b8 100644 --- a/apis/ec2/src/test/java/org/jclouds/ec2/compute/functions/RunningInstanceToNodeMetadataTest.java +++ b/apis/ec2/src/test/java/org/jclouds/ec2/compute/functions/RunningInstanceToNodeMetadataTest.java @@ -18,7 +18,7 @@ */ package org.jclouds.ec2.compute.functions; -import static org.jclouds.ec2.compute.domain.EC2HardwareBuilder.m1_small; +import static org.jclouds.ec2.compute.domain.EC2HardwareBuilder.m1_small32; import static org.testng.Assert.assertEquals; import java.net.UnknownHostException; @@ -129,7 +129,7 @@ public class RunningInstanceToNodeMetadataTest { @Test public void testApplyWhereTagDoesntMatchAndImageHardwareAndLocationFound() throws UnknownHostException { - RunningInstanceToNodeMetadata parser = createNodeParser(ImmutableSet.of(m1_small().build()), ImmutableSet + RunningInstanceToNodeMetadata parser = createNodeParser(ImmutableSet.of(m1_small32().build()), ImmutableSet .of(provider), EC2ImageParserTest.convertImages("/amzn_images.xml"), ImmutableMap . of()); @@ -137,7 +137,7 @@ public class RunningInstanceToNodeMetadataTest { assertEquals(parser.apply(server), new NodeMetadataBuilder().state(NodeState.RUNNING).privateAddresses( ImmutableSet.of("10.243.42.70")).publicAddresses(ImmutableSet.of("174.129.81.68")).imageId( - "us-east-1/ami-82e4b5c7").hardware(m1_small().build()).operatingSystem( + "us-east-1/ami-82e4b5c7").hardware(m1_small32().build()).operatingSystem( new OperatingSystem.Builder().family(OsFamily.UNRECOGNIZED).version("").arch("paravirtual").description( "137112412989/amzn-ami-0.9.7-beta.i386-ebs").is64Bit(false).build()).id("us-east-1/i-0799056f") .providerId("i-0799056f").location(provider).build()); @@ -158,7 +158,7 @@ public class RunningInstanceToNodeMetadataTest { }; Map instanceToImage = new MapMaker().makeComputingMap(nullReturningFunction); - RunningInstanceToNodeMetadata parser = createNodeParser(ImmutableSet.of(m1_small().build()), ImmutableSet + RunningInstanceToNodeMetadata parser = createNodeParser(ImmutableSet.of(m1_small32().build()), ImmutableSet .of(provider), ImmutableMap. of(), EC2ComputeServiceDependenciesModule.instanceToNodeState, instanceToImage); @@ -167,7 +167,7 @@ public class RunningInstanceToNodeMetadataTest { assertEquals(parser.apply(server), new NodeMetadataBuilder().state(NodeState.RUNNING).privateAddresses( ImmutableSet.of("10.243.42.70")).publicAddresses(ImmutableSet.of("174.129.81.68")).imageId( "us-east-1/ami-82e4b5c7").id("us-east-1/i-0799056f").providerId("i-0799056f").hardware( - m1_small().build()).location(provider).build()); + m1_small32().build()).location(provider).build()); } protected RunningInstance firstInstanceFromResource(String resource) { diff --git a/apis/ec2/src/test/java/org/jclouds/ec2/compute/strategy/CreateKeyPairAndSecurityGroupsAsNeededAndReturnRunOptionsTest.java b/apis/ec2/src/test/java/org/jclouds/ec2/compute/strategy/CreateKeyPairAndSecurityGroupsAsNeededAndReturnRunOptionsTest.java index 3cacd017a0..f54b6cca71 100644 --- a/apis/ec2/src/test/java/org/jclouds/ec2/compute/strategy/CreateKeyPairAndSecurityGroupsAsNeededAndReturnRunOptionsTest.java +++ b/apis/ec2/src/test/java/org/jclouds/ec2/compute/strategy/CreateKeyPairAndSecurityGroupsAsNeededAndReturnRunOptionsTest.java @@ -69,7 +69,7 @@ public class CreateKeyPairAndSecurityGroupsAsNeededAndReturnRunOptionsTest { // setup constants String region = Region.AP_SOUTHEAST_1; String tag = "tag"; - Hardware size = EC2HardwareBuilder.m1_small().build(); + Hardware size = EC2HardwareBuilder.m1_small32().build(); String systemGeneratedKeyPairName = "systemGeneratedKeyPair"; String generatedGroup = "group"; Set generatedGroups = ImmutableSet.of(generatedGroup); @@ -124,7 +124,7 @@ public class CreateKeyPairAndSecurityGroupsAsNeededAndReturnRunOptionsTest { // setup constants String region = Region.AP_SOUTHEAST_1; String tag = "tag"; - Hardware size = EC2HardwareBuilder.m1_small().build(); + Hardware size = EC2HardwareBuilder.m1_small32().build(); String systemGeneratedKeyPairName = "systemGeneratedKeyPair"; String generatedGroup = "group"; Set generatedGroups = ImmutableSet.of(generatedGroup); diff --git a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/suppliers/AWSEC2HardwareSupplier.java b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/suppliers/AWSEC2HardwareSupplier.java index c51c9897da..e16ff71084 100644 --- a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/suppliers/AWSEC2HardwareSupplier.java +++ b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/suppliers/AWSEC2HardwareSupplier.java @@ -24,7 +24,7 @@ import static org.jclouds.ec2.compute.domain.EC2HardwareBuilder.c1_medium; import static org.jclouds.ec2.compute.domain.EC2HardwareBuilder.c1_xlarge; import static org.jclouds.ec2.compute.domain.EC2HardwareBuilder.cc1_4xlarge; import static org.jclouds.ec2.compute.domain.EC2HardwareBuilder.m1_large; -import static org.jclouds.ec2.compute.domain.EC2HardwareBuilder.m1_small; +import static org.jclouds.ec2.compute.domain.EC2HardwareBuilder.m1_small32; import static org.jclouds.ec2.compute.domain.EC2HardwareBuilder.m1_xlarge; import static org.jclouds.ec2.compute.domain.EC2HardwareBuilder.m2_2xlarge; import static org.jclouds.ec2.compute.domain.EC2HardwareBuilder.m2_4xlarge; @@ -82,7 +82,7 @@ public class AWSEC2HardwareSupplier extends EC2HardwareSupplier { sizes.add(cc1_4xlarge().location(location).supportsImageIds(ccAmi).build()); } sizes.addAll(ImmutableSet. of(t1_micro().build(), c1_medium().build(), c1_xlarge().build(), m1_large() - .build(), m1_small().build(), m1_xlarge().build(), m2_xlarge().build(), m2_2xlarge().build(), + .build(), m1_small32().build(), m1_xlarge().build(), m2_xlarge().build(), m2_2xlarge().build(), m2_4xlarge().build())); return sizes.build(); } diff --git a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/compute/strategy/CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptionsTest.java b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/compute/strategy/CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptionsTest.java index f61a77b8ef..b5388a6c71 100644 --- a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/compute/strategy/CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptionsTest.java +++ b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/compute/strategy/CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptionsTest.java @@ -73,7 +73,7 @@ public class CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptionsT // setup constants String region = Region.AP_SOUTHEAST_1; String group = "group"; - Hardware size = EC2HardwareBuilder.m1_small().build(); + Hardware size = EC2HardwareBuilder.m1_small32().build(); String systemGeneratedKeyPairName = "systemGeneratedKeyPair"; String generatedGroup = "group"; Set generatedGroups = ImmutableSet.of(generatedGroup); @@ -262,7 +262,7 @@ public class CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptionsT // setup constants String region = Region.AP_SOUTHEAST_1; String group = "group"; - Hardware size = EC2HardwareBuilder.m1_small().build(); + Hardware size = EC2HardwareBuilder.m1_small32().build(); String systemGeneratedKeyPairName = "systemGeneratedKeyPair"; // create mocks @@ -320,7 +320,7 @@ public class CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptionsT // setup constants String region = Region.AP_SOUTHEAST_1; String group = "group"; - Hardware size = EC2HardwareBuilder.m1_small().build(); + Hardware size = EC2HardwareBuilder.m1_small32().build(); String systemGeneratedKeyPairName = "systemGeneratedKeyPair"; String generatedGroup = "group"; Set generatedGroups = ImmutableSet.of(generatedGroup); diff --git a/providers/eucalyptus-partnercloud-ec2/src/test/java/org/jclouds/epc/compute/EucalyptusPartnerCloudEucalyptusTemplateBuilderLiveTest.java b/providers/eucalyptus-partnercloud-ec2/src/test/java/org/jclouds/epc/compute/EucalyptusPartnerCloudEucalyptusTemplateBuilderLiveTest.java index 03193f81d4..bdd38a5d46 100644 --- a/providers/eucalyptus-partnercloud-ec2/src/test/java/org/jclouds/epc/compute/EucalyptusPartnerCloudEucalyptusTemplateBuilderLiveTest.java +++ b/providers/eucalyptus-partnercloud-ec2/src/test/java/org/jclouds/epc/compute/EucalyptusPartnerCloudEucalyptusTemplateBuilderLiveTest.java @@ -24,10 +24,13 @@ import static org.testng.Assert.assertEquals; import java.io.IOException; import java.util.Set; +import org.jclouds.aws.util.AWSUtils; import org.jclouds.compute.BaseTemplateBuilderLiveTest; import org.jclouds.compute.domain.OsFamily; import org.jclouds.compute.domain.OsFamilyVersion64Bit; import org.jclouds.compute.domain.Template; +import org.jclouds.domain.LocationScope; +import org.jclouds.ec2.compute.util.EC2ComputeUtils; import org.testng.annotations.Test; import com.google.common.base.Predicate; @@ -68,16 +71,18 @@ public class EucalyptusPartnerCloudEucalyptusTemplateBuilderLiveTest extends Bas @Test public void testDefaultTemplateBuilder() throws IOException { - Template defaultTemplate = context.getComputeService().templateBuilder().build(); assert (defaultTemplate.getImage().getProviderId().startsWith("emi-")) : defaultTemplate; assertEquals(defaultTemplate.getImage().getOperatingSystem().getVersion(), "10.04"); assertEquals(defaultTemplate.getImage().getOperatingSystem().is64Bit(), true); assertEquals(defaultTemplate.getImage().getOperatingSystem().getFamily(), OsFamily.UBUNTU); assertEquals(defaultTemplate.getImage().getUserMetadata().get("rootDeviceType"), "instance-store"); + assertEquals(defaultTemplate.getHardware().getId(), "m1.small"); assertEquals(defaultTemplate.getLocation().getId(), "kvm-cluster"); - assertEquals(getCores(defaultTemplate.getHardware()), 2.0d); - + assertEquals(defaultTemplate.getLocation().getScope(), LocationScope.ZONE); + assertEquals(AWSUtils.getRegionFromLocationOrNull(defaultTemplate.getLocation()), "Eucalyptus"); + assertEquals(EC2ComputeUtils.getZoneFromLocationOrNull(defaultTemplate.getLocation()), "kvm-cluster"); + assertEquals(getCores(defaultTemplate.getHardware()), 1.0d); } @Override From ac56adc2e169f038eb9302a011c34e51f0d96015 Mon Sep 17 00:00:00 2001 From: Adrian Cole Date: Thu, 2 Jun 2011 13:47:57 -0700 Subject: [PATCH 022/264] Issue 592:templateBuilder.fromTemplate loses location when more narrow than region --- .../org/jclouds/ec2/compute/options/EC2TemplateOptions.java | 2 +- .../compute/domain/internal/TemplateBuilderImpl.java | 1 + .../org/jclouds/compute/BaseTemplateBuilderLiveTest.java | 6 ++++++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/apis/ec2/src/main/java/org/jclouds/ec2/compute/options/EC2TemplateOptions.java b/apis/ec2/src/main/java/org/jclouds/ec2/compute/options/EC2TemplateOptions.java index 5f63ffbd10..1c44f71c93 100644 --- a/apis/ec2/src/main/java/org/jclouds/ec2/compute/options/EC2TemplateOptions.java +++ b/apis/ec2/src/main/java/org/jclouds/ec2/compute/options/EC2TemplateOptions.java @@ -509,6 +509,6 @@ public class EC2TemplateOptions extends TemplateOptions implements Cloneable { @Override public String toString() { return "[groupIds=" + groupIds + ", keyPair=" + keyPair + ", noKeyPair=" + noKeyPair + ", userData=" - + Arrays.toString(userData) + ", blockDeviceMappings=" + blockDeviceMappings + "]"; + + Arrays.toString(userData) + ", blockDeviceMappings=" + blockDeviceMappings.build() + "]"; } } diff --git a/compute/src/main/java/org/jclouds/compute/domain/internal/TemplateBuilderImpl.java b/compute/src/main/java/org/jclouds/compute/domain/internal/TemplateBuilderImpl.java index c03791bbd0..4c9c44949a 100644 --- a/compute/src/main/java/org/jclouds/compute/domain/internal/TemplateBuilderImpl.java +++ b/compute/src/main/java/org/jclouds/compute/domain/internal/TemplateBuilderImpl.java @@ -416,6 +416,7 @@ public class TemplateBuilderImpl implements TemplateBuilder { */ @Override public TemplateBuilder fromTemplate(Template template) { + location = template.getLocation(); fromHardware(template.getHardware()); fromImage(template.getImage()); options(template.getOptions()); diff --git a/compute/src/test/java/org/jclouds/compute/BaseTemplateBuilderLiveTest.java b/compute/src/test/java/org/jclouds/compute/BaseTemplateBuilderLiveTest.java index 5ae857f58a..75d9800e4e 100644 --- a/compute/src/test/java/org/jclouds/compute/BaseTemplateBuilderLiveTest.java +++ b/compute/src/test/java/org/jclouds/compute/BaseTemplateBuilderLiveTest.java @@ -101,6 +101,12 @@ public abstract class BaseTemplateBuilderLiveTest { assert getCores(fastest) >= getCores(smallest) : String.format("%s ! >= %s", fastest, smallest); } + public void testFromTemplate() { + Template defaultTemplate = context.getComputeService().templateBuilder().build(); + assertEquals(context.getComputeService().templateBuilder().fromTemplate(defaultTemplate).build().toString(), + defaultTemplate.toString()); + } + protected Properties setupProperties() { Properties overrides = new Properties(); overrides.setProperty(Constants.PROPERTY_TRUST_ALL_CERTS, "true"); From a68640351f7cfb9c2bbd5cf509586b7d52bf2c72 Mon Sep 17 00:00:00 2001 From: Adrian Cole Date: Thu, 2 Jun 2011 13:51:49 -0700 Subject: [PATCH 023/264] better error when last-modified header not found --- .../functions/ParseSystemAndUserMetadataFromHeaders.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/blobstore/src/main/java/org/jclouds/blobstore/functions/ParseSystemAndUserMetadataFromHeaders.java b/blobstore/src/main/java/org/jclouds/blobstore/functions/ParseSystemAndUserMetadataFromHeaders.java index 69c0f743d0..160881a2f9 100755 --- a/blobstore/src/main/java/org/jclouds/blobstore/functions/ParseSystemAndUserMetadataFromHeaders.java +++ b/blobstore/src/main/java/org/jclouds/blobstore/functions/ParseSystemAndUserMetadataFromHeaders.java @@ -94,8 +94,7 @@ public class ParseSystemAndUserMetadataFromHeaders implements Function Date: Thu, 2 Jun 2011 16:34:37 -0600 Subject: [PATCH 024/264] Issue 550: Added ProviderMetadata for Eucalyptus Partner Cloud S3. [in providers/eucalyptus-partnercloud-s3/src] * main/java/org/jclouds/epc/EucalyptusPartnerCloudS3ProviderMetadata.java, main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata, test/java/org/jclouds/epc/EucalyptusPartnerCloudS3ProviderTest.java: Added. --- ...alyptusPartnerCloudS3ProviderMetadata.java | 108 ++++++++++++++++++ .../org.jclouds.providers.ProviderMetadata | 1 + .../EucalyptusPartnerCloudS3ProviderTest.java | 37 ++++++ 3 files changed, 146 insertions(+) create mode 100644 providers/eucalyptus-partnercloud-s3/src/main/java/org/jclouds/epc/EucalyptusPartnerCloudS3ProviderMetadata.java create mode 100644 providers/eucalyptus-partnercloud-s3/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata create mode 100644 providers/eucalyptus-partnercloud-s3/src/test/java/org/jclouds/epc/EucalyptusPartnerCloudS3ProviderTest.java diff --git a/providers/eucalyptus-partnercloud-s3/src/main/java/org/jclouds/epc/EucalyptusPartnerCloudS3ProviderMetadata.java b/providers/eucalyptus-partnercloud-s3/src/main/java/org/jclouds/epc/EucalyptusPartnerCloudS3ProviderMetadata.java new file mode 100644 index 0000000000..0c1d6d2d38 --- /dev/null +++ b/providers/eucalyptus-partnercloud-s3/src/main/java/org/jclouds/epc/EucalyptusPartnerCloudS3ProviderMetadata.java @@ -0,0 +1,108 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.jclouds.epc; + +import com.google.common.collect.ImmutableSet; + +import java.net.URI; +import java.util.Set; + +import org.jclouds.providers.BaseProviderMetadata; + +/** + * Implementation of {@ link org.jclouds.types.ProviderMetadata} for Eucalpytus' + * Partner Cloud S3 provider. + * + * @author Jeremy Whitlock + */ +public class EucalyptusPartnerCloudS3ProviderMetadata extends BaseProviderMetadata { + + /** + * {@inheritDoc} + */ + @Override + public String getId() { + return "eucalyptus-partnercloud-s3"; + } + + /** + * {@inheritDoc} + */ + @Override + public String getType() { + return BLOBSTORE_TYPE; + } + + /** + * {@inheritDoc} + */ + @Override + public String getName() { + return "Eucalyptus Partner Cloud (S3)"; + } + + /** + * {@inheritDoc} + */ + @Override + public String getIdentityName() { + return "Username"; + } + + /** + * {@inheritDoc} + */ + @Override + public String getCredentialName() { + return "Password"; + } + + /** + * {@inheritDoc} + */ + @Override + public URI getHomepage() { + return URI.create("http://www.eucalyptus.com/partners"); + } + + /** + * {@inheritDoc} + */ + @Override + public URI getConsole() { + return URI.create("https://partnercloud.eucalyptus.com:8443"); + } + + /** + * {@inheritDoc} + */ + @Override + public URI getApiDocumentation() { + return URI.create("http://open.eucalyptus.com/wiki/IntroducingEucalyptus_v2.0"); + } + + /** + * {@inheritDoc} + */ + @Override + public Set getIso3166Codes() { + return ImmutableSet.of("US-CA"); + } + +} diff --git a/providers/eucalyptus-partnercloud-s3/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata b/providers/eucalyptus-partnercloud-s3/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata new file mode 100644 index 0000000000..55e706a690 --- /dev/null +++ b/providers/eucalyptus-partnercloud-s3/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata @@ -0,0 +1 @@ +org.jclouds.epc.EucalyptusPartnerCloudS3ProviderMetadata diff --git a/providers/eucalyptus-partnercloud-s3/src/test/java/org/jclouds/epc/EucalyptusPartnerCloudS3ProviderTest.java b/providers/eucalyptus-partnercloud-s3/src/test/java/org/jclouds/epc/EucalyptusPartnerCloudS3ProviderTest.java new file mode 100644 index 0000000000..027cead9ce --- /dev/null +++ b/providers/eucalyptus-partnercloud-s3/src/test/java/org/jclouds/epc/EucalyptusPartnerCloudS3ProviderTest.java @@ -0,0 +1,37 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.jclouds.epc; + +import org.jclouds.providers.BaseProviderMetadataTest; +import org.jclouds.providers.ProviderMetadata; +import org.testng.annotations.Test; + +/** + * The EucalyptusPartnerCloudS3ProviderTest tests the {@link EucalyptusPartnerCloudS3ProviderMetadata} class. + * + * @author Jeremy Whitlock + */ +@Test(groups = "unit", testName = "EucalyptusPartnerCloudS3ProviderTest") +public class EucalyptusPartnerCloudS3ProviderTest extends BaseProviderMetadataTest { + + public EucalyptusPartnerCloudS3ProviderTest() { + super(new EucalyptusPartnerCloudS3ProviderMetadata(), ProviderMetadata.BLOBSTORE_TYPE); + } + +} \ No newline at end of file From 83757913351ef5191382bd720b55c18fb07c387a Mon Sep 17 00:00:00 2001 From: Dmitri Babaev Date: Fri, 3 Jun 2011 02:38:00 +0400 Subject: [PATCH 025/264] comments for failing live tests fixes in change password test --- .../compute/NovaComputeServiceLiveTest.java | 1 + .../live/compute/ServiceActionsLiveTest.java | 4 +++- .../nova/live/novaclient/ClientBase.java | 21 +++++++++++++++++++ .../live/novaclient/NovaClientLiveTest.java | 9 ++++++++ 4 files changed, 34 insertions(+), 1 deletion(-) diff --git a/apis/nova/src/test/java/org/jclouds/openstack/nova/live/compute/NovaComputeServiceLiveTest.java b/apis/nova/src/test/java/org/jclouds/openstack/nova/live/compute/NovaComputeServiceLiveTest.java index 8e59615bba..66da04cc73 100644 --- a/apis/nova/src/test/java/org/jclouds/openstack/nova/live/compute/NovaComputeServiceLiveTest.java +++ b/apis/nova/src/test/java/org/jclouds/openstack/nova/live/compute/NovaComputeServiceLiveTest.java @@ -394,6 +394,7 @@ public class NovaComputeServiceLiveTest extends ComputeBase { @Test(timeOut = 60000) public void testListHardwareProfiles() throws Exception { + //TODO: failing, OpenStack returns a hardware with 0 CPU cores for (Hardware hardware : computeService.listHardwareProfiles()) { assert hardware.getProviderId() != null; assert getCores(hardware) > 0; diff --git a/apis/nova/src/test/java/org/jclouds/openstack/nova/live/compute/ServiceActionsLiveTest.java b/apis/nova/src/test/java/org/jclouds/openstack/nova/live/compute/ServiceActionsLiveTest.java index f45e189121..7d89e32af4 100644 --- a/apis/nova/src/test/java/org/jclouds/openstack/nova/live/compute/ServiceActionsLiveTest.java +++ b/apis/nova/src/test/java/org/jclouds/openstack/nova/live/compute/ServiceActionsLiveTest.java @@ -20,6 +20,7 @@ package org.jclouds.openstack.nova.live.compute; import com.google.common.base.Predicate; import com.google.common.collect.Iterables; +import com.sun.xml.internal.bind.v2.TODO; import org.jclouds.compute.domain.NodeMetadata; import org.jclouds.compute.domain.NodeState; import org.testng.annotations.AfterTest; @@ -56,8 +57,9 @@ public class ServiceActionsLiveTest extends ComputeBase { //testGetNodeMetadata(); } - @Test //Suspend is not supported by the provider yet + @Test public void testSuspendResume() throws Exception { + //TODO: failing, suspend is not supported by the nova provider yet getDefaultNodeImmediately(group); computeService.suspendNodesMatching(inGroup(group)); diff --git a/apis/nova/src/test/java/org/jclouds/openstack/nova/live/novaclient/ClientBase.java b/apis/nova/src/test/java/org/jclouds/openstack/nova/live/novaclient/ClientBase.java index e5755c0a53..62398bf50f 100644 --- a/apis/nova/src/test/java/org/jclouds/openstack/nova/live/novaclient/ClientBase.java +++ b/apis/nova/src/test/java/org/jclouds/openstack/nova/live/novaclient/ClientBase.java @@ -23,6 +23,8 @@ import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; import com.google.inject.Injector; import com.google.inject.Module; +import org.jclouds.domain.Credentials; +import org.jclouds.http.handlers.BackoffLimitedRetryHandler; import org.jclouds.logging.slf4j.config.SLF4JLoggingModule; import org.jclouds.net.IPSocket; import org.jclouds.openstack.nova.NovaClient; @@ -32,12 +34,16 @@ import org.jclouds.predicates.RetryablePredicate; import org.jclouds.predicates.SocketOpen; import org.jclouds.rest.RestContextFactory; import org.jclouds.ssh.SshClient; +import org.jclouds.ssh.SshException; +import org.jclouds.ssh.jsch.JschSshClient; import org.jclouds.ssh.jsch.config.JschSshClientModule; import org.testng.annotations.BeforeTest; import java.io.IOException; +import java.net.URISyntaxException; import java.util.Map; import java.util.Properties; +import java.util.Set; import java.util.concurrent.TimeUnit; import static org.jclouds.openstack.nova.live.PropertyHelper.*; @@ -112,4 +118,19 @@ public class ClientBase { Thread.sleep(1000); } } + + protected void awaitForSshPort(String address, Credentials credentials) throws URISyntaxException { + IPSocket socket = new IPSocket(address, 22); + + JschSshClient ssh = new JschSshClient( + new BackoffLimitedRetryHandler(), socket, 10000, credentials.identity, null, credentials.credential.getBytes()); + while (true) { + try { + System.out.println("ping: " + socket); + ssh.connect(); + return; + } catch (SshException ignore) { + } + } + } } diff --git a/apis/nova/src/test/java/org/jclouds/openstack/nova/live/novaclient/NovaClientLiveTest.java b/apis/nova/src/test/java/org/jclouds/openstack/nova/live/novaclient/NovaClientLiveTest.java index d6da4aed0e..b10c1d9e47 100644 --- a/apis/nova/src/test/java/org/jclouds/openstack/nova/live/novaclient/NovaClientLiveTest.java +++ b/apis/nova/src/test/java/org/jclouds/openstack/nova/live/novaclient/NovaClientLiveTest.java @@ -20,6 +20,7 @@ package org.jclouds.openstack.nova.live.novaclient; import com.google.common.collect.Iterables; +import com.sun.xml.internal.bind.v2.TODO; import org.jclouds.domain.Credentials; import org.jclouds.http.HttpResponseException; import org.jclouds.io.Payload; @@ -57,6 +58,7 @@ public class NovaClientLiveTest extends ClientBase { @Test public void testListServersDetail() throws Exception { + //TODO: failing, /v1.1/servers/{server id}/ips URL is not available (issue in the OpenStack) Set response = client.listServers(withDetails()); assert null != response; long initialContainerCount = response.size(); @@ -65,6 +67,7 @@ public class NovaClientLiveTest extends ClientBase { @Test public void testListImages() throws Exception { + //TODO: failing, image name should not be null (issue in the OpenStack) Set response = client.listImages(); assert null != response; long imageCount = response.size(); @@ -78,6 +81,7 @@ public class NovaClientLiveTest extends ClientBase { @Test public void testListImagesDetail() throws Exception { + //TODO: failing, image name should not be null (issue in the OpenStack) Set response = client.listImages(withDetails()); assert null != response; long imageCount = response.size(); @@ -276,6 +280,8 @@ public class NovaClientLiveTest extends ClientBase { public void testChangePassword() throws Exception { int serverId = getDefaultServerImmediately().getId(); blockUntilServerActive(serverId); + blockUntilPublicAddress(serverId); + awaitForSshPort(Iterables.get(client.getServer(serverId).getAddresses().getPublicAddresses(), 0).getAddress(), new Credentials("root", keyPair.get("private"))); client.changeAdminPass(serverId, "elmo"); assertPassword(client.getServer(serverId), "elmo"); @@ -283,6 +289,7 @@ public class NovaClientLiveTest extends ClientBase { @Test(enabled = true, timeOut = 10 * 600 * 1000) public void testCreateImage() throws Exception { + //TODO: failing, create image from instance returns incorrect JSON Server server = getDefaultServerImmediately(); Image image = getDefaultImageImmediately(server); blockUntilImageActive(image.getId()); @@ -293,6 +300,7 @@ public class NovaClientLiveTest extends ClientBase { @Test(enabled = true, timeOut = 10 * 60 * 1000) public void testRebuildServer() throws Exception { + //TODO: failing, create image from instance returns incorrect JSON Server server = getDefaultServerImmediately(); Image image = getDefaultImageImmediately(server); client.rebuildServer(server.getId(), new RebuildServerOptions().withImage(String.valueOf(image.getId()))); @@ -349,6 +357,7 @@ public class NovaClientLiveTest extends ClientBase { @Test(enabled = true, timeOut = 60000) void testDeleteImage() throws Exception { + //TODO: failing, create image from instance returns incorrect JSON Image image = getDefaultImageImmediately(getDefaultServerImmediately()); client.deleteImage(image.getId()); assert client.getImage(image.getId()) == null; From 8a8daaa372f7cc2dc17f034171d3e6f70ea67e27 Mon Sep 17 00:00:00 2001 From: Adrian Cole Date: Thu, 2 Jun 2011 15:45:45 -0700 Subject: [PATCH 026/264] revised rimu tests --- .../rimuhosting/miro/RimuHostingPropertiesBuilder.java | 2 ++ .../miro/compute/RimuHostingComputeServiceLiveTest.java | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/sandbox-providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/RimuHostingPropertiesBuilder.java b/sandbox-providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/RimuHostingPropertiesBuilder.java index e8e9a5c0ac..cdea040357 100644 --- a/sandbox-providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/RimuHostingPropertiesBuilder.java +++ b/sandbox-providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/RimuHostingPropertiesBuilder.java @@ -31,6 +31,7 @@ import static org.jclouds.rimuhosting.miro.reference.RimuHostingConstants.PROPER import java.util.Properties; import org.jclouds.PropertiesBuilder; +import org.jclouds.compute.reference.ComputeServiceConstants; import org.jclouds.concurrent.Timeout; /** @@ -55,6 +56,7 @@ public class RimuHostingPropertiesBuilder extends PropertiesBuilder { long timeoutMillis = timeout.timeUnit().toMillis(timeout.duration()); properties.setProperty(PROPERTY_SO_TIMEOUT, timeoutMillis + ""); properties.setProperty(PROPERTY_CONNECTION_TIMEOUT, timeoutMillis + ""); + properties.setProperty(ComputeServiceConstants.PROPERTY_TIMEOUT_NODE_TERMINATED, 60 * 1000 + ""); return properties; } diff --git a/sandbox-providers/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/compute/RimuHostingComputeServiceLiveTest.java b/sandbox-providers/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/compute/RimuHostingComputeServiceLiveTest.java index 4af778afc2..974864b1a1 100755 --- a/sandbox-providers/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/compute/RimuHostingComputeServiceLiveTest.java +++ b/sandbox-providers/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/compute/RimuHostingComputeServiceLiveTest.java @@ -43,4 +43,8 @@ public class RimuHostingComputeServiceLiveTest extends BaseComputeServiceLiveTes return new JschSshClientModule(); } + @Override + public void testOptionToNotBlock() { + // start call is blocking anyway. + } } From 07e6088bdb97145548387693cc2ffd44aebe66ce Mon Sep 17 00:00:00 2001 From: Dmitri Babaev Date: Fri, 3 Jun 2011 02:46:16 +0400 Subject: [PATCH 027/264] incorrect imports fix --- .../openstack/nova/live/compute/ServiceActionsLiveTest.java | 1 - .../openstack/nova/live/novaclient/NovaClientLiveTest.java | 1 - 2 files changed, 2 deletions(-) diff --git a/apis/nova/src/test/java/org/jclouds/openstack/nova/live/compute/ServiceActionsLiveTest.java b/apis/nova/src/test/java/org/jclouds/openstack/nova/live/compute/ServiceActionsLiveTest.java index 7d89e32af4..f3f2885abf 100644 --- a/apis/nova/src/test/java/org/jclouds/openstack/nova/live/compute/ServiceActionsLiveTest.java +++ b/apis/nova/src/test/java/org/jclouds/openstack/nova/live/compute/ServiceActionsLiveTest.java @@ -20,7 +20,6 @@ package org.jclouds.openstack.nova.live.compute; import com.google.common.base.Predicate; import com.google.common.collect.Iterables; -import com.sun.xml.internal.bind.v2.TODO; import org.jclouds.compute.domain.NodeMetadata; import org.jclouds.compute.domain.NodeState; import org.testng.annotations.AfterTest; diff --git a/apis/nova/src/test/java/org/jclouds/openstack/nova/live/novaclient/NovaClientLiveTest.java b/apis/nova/src/test/java/org/jclouds/openstack/nova/live/novaclient/NovaClientLiveTest.java index b10c1d9e47..0a64f3cdc9 100644 --- a/apis/nova/src/test/java/org/jclouds/openstack/nova/live/novaclient/NovaClientLiveTest.java +++ b/apis/nova/src/test/java/org/jclouds/openstack/nova/live/novaclient/NovaClientLiveTest.java @@ -20,7 +20,6 @@ package org.jclouds.openstack.nova.live.novaclient; import com.google.common.collect.Iterables; -import com.sun.xml.internal.bind.v2.TODO; import org.jclouds.domain.Credentials; import org.jclouds.http.HttpResponseException; import org.jclouds.io.Payload; From a069981e74a6421174243975ba2a73a95cedc2cd Mon Sep 17 00:00:00 2001 From: Kedar Dave Date: Thu, 2 Jun 2011 17:47:45 -0500 Subject: [PATCH 028/264] cleanup tests, added ProviderMetadata implementation for savis-symphonyvpdc --- .../SavvisSymphonyVPDCProviderMetadata.java | 141 ++++++++++++++++++ .../vpdc/features/BrowsingClientLiveTest.java | 6 +- .../ServiceManagementClientLiveTest.java | 20 ++- 3 files changed, 158 insertions(+), 9 deletions(-) create mode 100644 providers/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/SavvisSymphonyVPDCProviderMetadata.java diff --git a/providers/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/SavvisSymphonyVPDCProviderMetadata.java b/providers/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/SavvisSymphonyVPDCProviderMetadata.java new file mode 100644 index 0000000000..01f9a9ef9f --- /dev/null +++ b/providers/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/SavvisSymphonyVPDCProviderMetadata.java @@ -0,0 +1,141 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.jclouds.savvis.vpdc; + +import com.google.common.collect.ImmutableSet; + +import java.net.URI; +import java.util.Set; + +import org.jclouds.providers.BaseProviderMetadata; +import org.jclouds.providers.ProviderMetadata; + +/** + * Implementation of {@link org.jclouds.types.ProviderMetadata} for Savvis Symphony VPDC services. + * + * @author Kedar Dave + */ +public class SavvisSymphonyVPDCProviderMetadata extends BaseProviderMetadata { + + /** + * {@inheritDoc} + */ + @Override + public String getId() { + return "savvis-symphonyvpdc"; + } + + /** + * {@inheritDoc} + */ + @Override + public String getType() { + return ProviderMetadata.COMPUTE_TYPE; + } + + /** + * {@inheritDoc} + */ + @Override + public String getName() { + return "Savvis Symphony VPDC"; + } + + /** + * {@inheritDoc} + */ + @Override + public String getIdentityName() { + return "username"; + } + + /** + * {@inheritDoc} + */ + @Override + public String getCredentialName() { + return "password"; + } + + /** + * {@inheritDoc} + */ + @Override + public URI getHomepage() { + return URI.create("http://www.savvis.com/en-US/infrastructure-services/Cloud/Pages/SavvisSymphonyVPDC.aspx"); + } + + /** + * {@inheritDoc} + */ + @Override + public URI getConsole() { + return URI.create("https://www.savvisstation.com"); + } + + /** + * {@inheritDoc} + */ + @Override + public URI getApiDocumentation() { + return URI.create("https://api.symphonyvpdc.savvis.net/doc/spec/api/index.html"); + } + + /** + * {@inheritDoc} + * list of data centers from savvisstation colocation guide + * https://www.savvisstation.com/DocumentViewer?GUID=a95f0387-cbfe-43eb-b25b-4f2b0f68498f&sessionid=SavvisCCC%3ac9a8984b9655b01916be587e5204b2cf + * Once we have confirmation from Savvis as to what data centers are used for vpdc deployments, + * iso codes for those will be entered here + * + * City Code + * Lithia Springs, GA AT1 + * Waltham, MA BO1 + * Waltham, MA BO2 + * Waltham, MA B03 + * Elk Grove Village, IL CH3 + * Chicago, IL CH4 + * Sterling, VA DC2 + * Sterling, VA DC3 + * Sterling, VA DC4 Phase I + * Sterling, VA DC4 Phase II + * Fort Worth, TX DL1 + * Fort Worth, TX DL2 + * El Segundo, CA LA1 + * Jersey City, NJ NJ1 + * Weehawken, NJ NJ2 + * Piscataway, NJ NJ3 + * Piscataway, NJ 2nd floor NJ3 + * Weehawken, NJ NJ2X + * Irvine, CA OC2 + * Santa Clara, CA SC4 + * Santa Clara, CA SC5 + * Santa Clara, CA SC8 + * Santa Clara, CA SC9 + * Tukwila, WA 1st floor SE2 + * Montreal, Canada MR1 + * Toronto, Canada TR1 + * Vancouver, Canada VC1 + */ + @Override + public Set getIso3166Codes() { + return ImmutableSet.of(""); + } + +} \ No newline at end of file diff --git a/providers/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/features/BrowsingClientLiveTest.java b/providers/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/features/BrowsingClientLiveTest.java index 738400a5cb..8d37bb4d61 100644 --- a/providers/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/features/BrowsingClientLiveTest.java +++ b/providers/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/features/BrowsingClientLiveTest.java @@ -115,11 +115,13 @@ public class BrowsingClientLiveTest extends BaseVPDCClientLiveTest { } } + // test for a single vm, as savvis response times are very slow. So if there are multiple vpdc's with numerous vm's, + // test execution will invariably take a long time @Test public void testVM() throws Exception { for (Resource org1 : restContext.getApi().listOrgs()) { Org org = client.getOrg(org1.getId()); - for (Resource vdc : org.getVDCs()) { + VDC_LOOP : for (Resource vdc : org.getVDCs()) { VDC VDC = client.getVDCInOrg(org.getId(), vdc.getId()); for (Resource vApp : Iterables.filter(VDC.getResourceEntities(), new Predicate() { @@ -158,8 +160,8 @@ public class BrowsingClientLiveTest extends BaseVPDCClientLiveTest { assert HostSpecifier.isValid(ip) : response; } } + break VDC_LOOP; } - } } } diff --git a/providers/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/features/ServiceManagementClientLiveTest.java b/providers/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/features/ServiceManagementClientLiveTest.java index 4c7fbceece..40963d9fbc 100644 --- a/providers/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/features/ServiceManagementClientLiveTest.java +++ b/providers/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/features/ServiceManagementClientLiveTest.java @@ -27,6 +27,7 @@ import java.util.concurrent.TimeoutException; import org.jclouds.savvis.vpdc.domain.Org; import org.jclouds.savvis.vpdc.domain.Resource; +import org.jclouds.savvis.vpdc.domain.Task; import org.jclouds.savvis.vpdc.domain.VDC; import org.jclouds.savvis.vpdc.domain.VM; import org.jclouds.savvis.vpdc.reference.VCloudMediaType; @@ -47,11 +48,13 @@ public class ServiceManagementClientLiveTest extends BaseVPDCClientLiveTest { super.setupClient(); client = restContext.getApi().getServiceManagementClient(); } - + + // test for a single vm, as savvis response times are very slow. So if there are multiple vpdc's with numerous vm's, + // test execution will invariably take a long time public void testLifeCycle() throws InterruptedException, ExecutionException, TimeoutException, IOException { for (Resource org1 : restContext.getApi().listOrgs()) { Org org = restContext.getApi().getBrowsingClient().getOrg(org1.getId()); - for (Resource vdc : org.getVDCs()) { + VDC_LOOP : for (Resource vdc : org.getVDCs()) { VDC VDC = restContext.getApi().getBrowsingClient().getVDCInOrg(org.getId(), vdc.getId()); for (Resource vmHandle : Iterables.filter(VDC.getResourceEntities(), new Predicate() { @@ -61,18 +64,21 @@ public class ServiceManagementClientLiveTest extends BaseVPDCClientLiveTest { } })) { - - assert taskTester.apply(client.powerOffVM(vmHandle.getHref()).getId()); + + Task powerOffTask = client.powerOffVM(vmHandle.getHref()); + assert taskTester.apply(powerOffTask.getId()); VM vm = restContext.getApi().getBrowsingClient().getVM(vmHandle.getHref(), withPowerState()); assertEquals(vm.getStatus(), VM.Status.OFF); - - assert taskTester.apply(client.powerOnVM(vmHandle.getHref()).getId()); + + Task powerOnTask = client.powerOnVM(vmHandle.getHref()); + assert taskTester.apply(powerOnTask.getId()); vm = restContext.getApi().getBrowsingClient().getVM(vmHandle.getHref(), withPowerState()); assertEquals(vm.getStatus(), VM.Status.ON); - + + break VDC_LOOP; } } } From 3ea6b290d1f1a8f88d0564778954c5c8d2a0cae0 Mon Sep 17 00:00:00 2001 From: Jeremy Whitlock Date: Thu, 2 Jun 2011 16:50:57 -0600 Subject: [PATCH 029/264] Issue 550: Added ProviderMetadata for Eucalyptus Partner Cloud EC2. [in providers/eucalyptus-partnercloud-ec2/src] * main/java/org/jclouds/epc/EucalyptusPartnerCloudEC2ProviderMetadata.java, main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata, test/java/org/jclouds/epc/EucalyptusPartnerCloudEC2ProviderTest.java: Added. --- ...lyptusPartnerCloudEC2ProviderMetadata.java | 108 ++++++++++++++++++ .../org.jclouds.providers.ProviderMetadata | 1 + ...EucalyptusPartnerCloudEC2ProviderTest.java | 37 ++++++ 3 files changed, 146 insertions(+) create mode 100644 providers/eucalyptus-partnercloud-ec2/src/main/java/org/jclouds/epc/EucalyptusPartnerCloudEC2ProviderMetadata.java create mode 100644 providers/eucalyptus-partnercloud-ec2/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata create mode 100644 providers/eucalyptus-partnercloud-ec2/src/test/java/org/jclouds/epc/EucalyptusPartnerCloudEC2ProviderTest.java diff --git a/providers/eucalyptus-partnercloud-ec2/src/main/java/org/jclouds/epc/EucalyptusPartnerCloudEC2ProviderMetadata.java b/providers/eucalyptus-partnercloud-ec2/src/main/java/org/jclouds/epc/EucalyptusPartnerCloudEC2ProviderMetadata.java new file mode 100644 index 0000000000..c18ed12397 --- /dev/null +++ b/providers/eucalyptus-partnercloud-ec2/src/main/java/org/jclouds/epc/EucalyptusPartnerCloudEC2ProviderMetadata.java @@ -0,0 +1,108 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.jclouds.epc; + +import com.google.common.collect.ImmutableSet; + +import java.net.URI; +import java.util.Set; + +import org.jclouds.providers.BaseProviderMetadata; + +/** + * Implementation of {@ link org.jclouds.types.ProviderMetadata} for Eucalpytus' + * Partner Cloud EC2 provider. + * + * @author Jeremy Whitlock + */ +public class EucalyptusPartnerCloudEC2ProviderMetadata extends BaseProviderMetadata { + + /** + * {@inheritDoc} + */ + @Override + public String getId() { + return "eucalyptus-partnercloud-ec2"; + } + + /** + * {@inheritDoc} + */ + @Override + public String getType() { + return COMPUTE_TYPE; + } + + /** + * {@inheritDoc} + */ + @Override + public String getName() { + return "Eucalyptus Partner Cloud (EC2)"; + } + + /** + * {@inheritDoc} + */ + @Override + public String getIdentityName() { + return "Username"; + } + + /** + * {@inheritDoc} + */ + @Override + public String getCredentialName() { + return "Password"; + } + + /** + * {@inheritDoc} + */ + @Override + public URI getHomepage() { + return URI.create("http://www.eucalyptus.com/partners"); + } + + /** + * {@inheritDoc} + */ + @Override + public URI getConsole() { + return URI.create("https://partnercloud.eucalyptus.com:8443"); + } + + /** + * {@inheritDoc} + */ + @Override + public URI getApiDocumentation() { + return URI.create("http://open.eucalyptus.com/wiki/IntroducingEucalyptus_v2.0"); + } + + /** + * {@inheritDoc} + */ + @Override + public Set getIso3166Codes() { + return ImmutableSet.of("US-CA"); + } + +} diff --git a/providers/eucalyptus-partnercloud-ec2/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata b/providers/eucalyptus-partnercloud-ec2/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata new file mode 100644 index 0000000000..1afa66de43 --- /dev/null +++ b/providers/eucalyptus-partnercloud-ec2/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata @@ -0,0 +1 @@ +org.jclouds.epc.EucalyptusPartnerCloudEC2ProviderMetadata diff --git a/providers/eucalyptus-partnercloud-ec2/src/test/java/org/jclouds/epc/EucalyptusPartnerCloudEC2ProviderTest.java b/providers/eucalyptus-partnercloud-ec2/src/test/java/org/jclouds/epc/EucalyptusPartnerCloudEC2ProviderTest.java new file mode 100644 index 0000000000..41659cefd9 --- /dev/null +++ b/providers/eucalyptus-partnercloud-ec2/src/test/java/org/jclouds/epc/EucalyptusPartnerCloudEC2ProviderTest.java @@ -0,0 +1,37 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.jclouds.epc; + +import org.jclouds.providers.BaseProviderMetadataTest; +import org.jclouds.providers.ProviderMetadata; +import org.testng.annotations.Test; + +/** + * The EucalyptusPartnerCloudEC2ProviderTest tests the {@link EucalyptusPartnerCloudEC2ProviderMetadata} class. + * + * @author Jeremy Whitlock + */ +@Test(groups = "unit", testName = "EucalyptusPartnerCloudEC2ProviderTest") +public class EucalyptusPartnerCloudEC2ProviderTest extends BaseProviderMetadataTest { + + public EucalyptusPartnerCloudEC2ProviderTest() { + super(new EucalyptusPartnerCloudEC2ProviderMetadata(), ProviderMetadata.COMPUTE_TYPE); + } + +} \ No newline at end of file From bde692ab7c1e6256b1c1de18374b69109bf719f4 Mon Sep 17 00:00:00 2001 From: Dmitri Babaev Date: Fri, 3 Jun 2011 03:09:43 +0400 Subject: [PATCH 030/264] non-working live tests is disabled (they are not working due to the issues with OpenStack) --- .../compute/NovaComputeServiceLiveTest.java | 2 +- .../live/compute/ServiceActionsLiveTest.java | 2 +- .../nova/live/novaclient/ClientBase.java | 15 --------------- .../live/novaclient/NovaClientLiveTest.java | 18 +++++++++--------- 4 files changed, 11 insertions(+), 26 deletions(-) diff --git a/apis/nova/src/test/java/org/jclouds/openstack/nova/live/compute/NovaComputeServiceLiveTest.java b/apis/nova/src/test/java/org/jclouds/openstack/nova/live/compute/NovaComputeServiceLiveTest.java index 66da04cc73..97571b0aa8 100644 --- a/apis/nova/src/test/java/org/jclouds/openstack/nova/live/compute/NovaComputeServiceLiveTest.java +++ b/apis/nova/src/test/java/org/jclouds/openstack/nova/live/compute/NovaComputeServiceLiveTest.java @@ -392,7 +392,7 @@ public class NovaComputeServiceLiveTest extends ComputeBase { assertEquals(provider.getParent(), null); } - @Test(timeOut = 60000) + @Test(timeOut = 60000, enabled = false) public void testListHardwareProfiles() throws Exception { //TODO: failing, OpenStack returns a hardware with 0 CPU cores for (Hardware hardware : computeService.listHardwareProfiles()) { diff --git a/apis/nova/src/test/java/org/jclouds/openstack/nova/live/compute/ServiceActionsLiveTest.java b/apis/nova/src/test/java/org/jclouds/openstack/nova/live/compute/ServiceActionsLiveTest.java index f3f2885abf..e9696ab1ef 100644 --- a/apis/nova/src/test/java/org/jclouds/openstack/nova/live/compute/ServiceActionsLiveTest.java +++ b/apis/nova/src/test/java/org/jclouds/openstack/nova/live/compute/ServiceActionsLiveTest.java @@ -56,7 +56,7 @@ public class ServiceActionsLiveTest extends ComputeBase { //testGetNodeMetadata(); } - @Test + @Test(enabled = false) public void testSuspendResume() throws Exception { //TODO: failing, suspend is not supported by the nova provider yet getDefaultNodeImmediately(group); diff --git a/apis/nova/src/test/java/org/jclouds/openstack/nova/live/novaclient/ClientBase.java b/apis/nova/src/test/java/org/jclouds/openstack/nova/live/novaclient/ClientBase.java index 62398bf50f..047e8b1342 100644 --- a/apis/nova/src/test/java/org/jclouds/openstack/nova/live/novaclient/ClientBase.java +++ b/apis/nova/src/test/java/org/jclouds/openstack/nova/live/novaclient/ClientBase.java @@ -118,19 +118,4 @@ public class ClientBase { Thread.sleep(1000); } } - - protected void awaitForSshPort(String address, Credentials credentials) throws URISyntaxException { - IPSocket socket = new IPSocket(address, 22); - - JschSshClient ssh = new JschSshClient( - new BackoffLimitedRetryHandler(), socket, 10000, credentials.identity, null, credentials.credential.getBytes()); - while (true) { - try { - System.out.println("ping: " + socket); - ssh.connect(); - return; - } catch (SshException ignore) { - } - } - } } diff --git a/apis/nova/src/test/java/org/jclouds/openstack/nova/live/novaclient/NovaClientLiveTest.java b/apis/nova/src/test/java/org/jclouds/openstack/nova/live/novaclient/NovaClientLiveTest.java index 0a64f3cdc9..0c149fe4f9 100644 --- a/apis/nova/src/test/java/org/jclouds/openstack/nova/live/novaclient/NovaClientLiveTest.java +++ b/apis/nova/src/test/java/org/jclouds/openstack/nova/live/novaclient/NovaClientLiveTest.java @@ -55,7 +55,7 @@ public class NovaClientLiveTest extends ClientBase { assertTrue(initialContainerCount >= 0); } - @Test + @Test(enabled = false) public void testListServersDetail() throws Exception { //TODO: failing, /v1.1/servers/{server id}/ips URL is not available (issue in the OpenStack) Set response = client.listServers(withDetails()); @@ -64,7 +64,7 @@ public class NovaClientLiveTest extends ClientBase { assertTrue(initialContainerCount >= 0); } - @Test + @Test(enabled = false) public void testListImages() throws Exception { //TODO: failing, image name should not be null (issue in the OpenStack) Set response = client.listImages(); @@ -78,7 +78,7 @@ public class NovaClientLiveTest extends ClientBase { } - @Test + @Test(enabled = false) public void testListImagesDetail() throws Exception { //TODO: failing, image name should not be null (issue in the OpenStack) Set response = client.listImages(withDetails()); @@ -248,7 +248,6 @@ public class NovaClientLiveTest extends ClientBase { assert server.getProgress() >= 0 : "newDetails.getProgress()" + server.getProgress(); } - private void assertPassword(Server server, String pass) throws IOException { IPSocket socket = new IPSocket(Iterables.get(server.getAddresses().getPublicAddresses(), 0).getAddress(), 22); //socketTester.apply(socket); @@ -275,18 +274,19 @@ public class NovaClientLiveTest extends ClientBase { assertEquals(oldName + "new", client.getServer(serverId).getName()); } - @Test(enabled = true, timeOut = 5 * 60 * 1000) + @Test(enabled = false, timeOut = 5 * 60 * 1000) public void testChangePassword() throws Exception { + //TODO: failing, fix acceptPassword method logic, however password is not changed by OpenStack int serverId = getDefaultServerImmediately().getId(); blockUntilServerActive(serverId); blockUntilPublicAddress(serverId); - awaitForSshPort(Iterables.get(client.getServer(serverId).getAddresses().getPublicAddresses(), 0).getAddress(), new Credentials("root", keyPair.get("private"))); client.changeAdminPass(serverId, "elmo"); + //TODO: wait until SSH is available assertPassword(client.getServer(serverId), "elmo"); } - @Test(enabled = true, timeOut = 10 * 600 * 1000) + @Test(enabled = false, timeOut = 10 * 600 * 1000) public void testCreateImage() throws Exception { //TODO: failing, create image from instance returns incorrect JSON Server server = getDefaultServerImmediately(); @@ -297,7 +297,7 @@ public class NovaClientLiveTest extends ClientBase { } - @Test(enabled = true, timeOut = 10 * 60 * 1000) + @Test(enabled = false, timeOut = 10 * 60 * 1000) public void testRebuildServer() throws Exception { //TODO: failing, create image from instance returns incorrect JSON Server server = getDefaultServerImmediately(); @@ -354,7 +354,7 @@ public class NovaClientLiveTest extends ClientBase { waitServerDeleted(serverId); } - @Test(enabled = true, timeOut = 60000) + @Test(enabled = false, timeOut = 60000) void testDeleteImage() throws Exception { //TODO: failing, create image from instance returns incorrect JSON Image image = getDefaultImageImmediately(getDefaultServerImmediately()); From 389943558810b63d149a34e341d81cc4ab7111c7 Mon Sep 17 00:00:00 2001 From: Adrian Cole Date: Thu, 2 Jun 2011 16:22:50 -0700 Subject: [PATCH 031/264] Issue 593:add rimu hosting to supported providers list --- README.txt | 4 ++-- allcompute/pom.xml | 5 +++++ providers/pom.xml | 1 + {sandbox-providers => providers}/rimuhosting/README.txt | 0 {sandbox-providers => providers}/rimuhosting/pom.xml | 0 .../org/jclouds/rimuhosting/miro/RimuHostingAsyncClient.java | 0 .../java/org/jclouds/rimuhosting/miro/RimuHostingClient.java | 0 .../jclouds/rimuhosting/miro/RimuHostingContextBuilder.java | 0 .../rimuhosting/miro/RimuHostingPropertiesBuilder.java | 0 .../jclouds/rimuhosting/miro/binder/CreateServerOptions.java | 0 .../rimuhosting/miro/binder/RimuHostingJsonBinder.java | 0 .../rimuhosting/miro/binder/RimuHostingRebootJsonBinder.java | 0 .../config/RimuHostingBindComputeStrategiesByClass.java | 0 .../config/RimuHostingBindComputeSuppliersByClass.java | 0 .../config/RimuHostingComputeServiceContextModule.java | 0 .../config/RimuHostingComputeServiceDependenciesModule.java | 0 .../miro/compute/functions/ServerToNodeMetadata.java | 0 .../RimuHostingCreateNodeWithGroupEncodedIntoName.java | 0 .../compute/strategy/RimuHostingDestroyNodeStrategy.java | 0 .../compute/strategy/RimuHostingGetNodeMetadataStrategy.java | 0 .../miro/compute/strategy/RimuHostingLifeCycleStrategy.java | 0 .../miro/compute/strategy/RimuHostingListNodesStrategy.java | 0 .../suppliers/RimuHostingDefaultLocationSupplier.java | 0 .../miro/compute/suppliers/RimuHostingHardwareSupplier.java | 0 .../miro/compute/suppliers/RimuHostingImageSupplier.java | 0 .../miro/compute/suppliers/RimuHostingLocationSupplier.java | 0 .../rimuhosting/miro/config/RimuHostingRestClientModule.java | 0 .../java/org/jclouds/rimuhosting/miro/data/CloneOptions.java | 0 .../org/jclouds/rimuhosting/miro/data/CreateOptions.java | 0 .../org/jclouds/rimuhosting/miro/data/IpRequestData.java | 0 .../org/jclouds/rimuhosting/miro/data/NewServerData.java | 0 .../java/org/jclouds/rimuhosting/miro/data/PostData.java | 0 .../org/jclouds/rimuhosting/miro/domain/BillingData.java | 0 .../java/org/jclouds/rimuhosting/miro/domain/DataCenter.java | 0 .../rimuhosting/miro/domain/DataTransferAllowance.java | 0 .../main/java/org/jclouds/rimuhosting/miro/domain/Image.java | 0 .../org/jclouds/rimuhosting/miro/domain/IpAddresses.java | 0 .../java/org/jclouds/rimuhosting/miro/domain/MetaData.java | 0 .../jclouds/rimuhosting/miro/domain/NewServerResponse.java | 0 .../org/jclouds/rimuhosting/miro/domain/PricingPlan.java | 0 .../org/jclouds/rimuhosting/miro/domain/ResizeResponse.java | 0 .../org/jclouds/rimuhosting/miro/domain/ResizeResult.java | 0 .../java/org/jclouds/rimuhosting/miro/domain/Server.java | 0 .../java/org/jclouds/rimuhosting/miro/domain/ServerInfo.java | 0 .../jclouds/rimuhosting/miro/domain/ServerParameters.java | 0 .../rimuhosting/miro/domain/internal/RimuHostingError.java | 0 .../miro/domain/internal/RimuHostingResponse.java | 0 .../miro/domain/internal/RimuHostingTimestamp.java | 0 .../rimuhosting/miro/domain/internal/RunningState.java | 0 .../jclouds/rimuhosting/miro/domain/internal/ServerType.java | 0 .../rimuhosting/miro/filters/RimuHostingAuthentication.java | 0 .../miro/functions/ParseDestroyResponseFromJsonResponse.java | 0 .../miro/functions/ParseImagesFromJsonResponse.java | 0 .../miro/functions/ParsePricingPlansFromJsonResponse.java | 0 .../miro/functions/ParseRimuHostingException.java | 0 .../miro/functions/ParseServerFromJsonResponse.java | 0 .../miro/functions/ParseServerInfoFromJsonResponse.java | 0 .../miro/functions/ParseServersFromJsonResponse.java | 0 .../jclouds/rimuhosting/miro/predicates/ServerDestroyed.java | 0 .../jclouds/rimuhosting/miro/predicates/ServerRunning.java | 0 .../rimuhosting/miro/reference/RimuHostingConstants.java | 0 .../jclouds/rimuhosting/miro/ProvidersInPropertiesTest.java | 0 .../jclouds/rimuhosting/miro/RimuHostingAsyncClientTest.java | 0 .../jclouds/rimuhosting/miro/RimuHostingClientLiveTest.java | 0 .../miro/compute/RimuHostingComputeServiceLiveTest.java | 0 .../miro/compute/RimuHostingTemplateBuilderLiveTest.java | 0 .../config/RimuHostingComputeServiceContextModuleTest.java | 0 .../miro/functions/ParseServerFromJsonResponseTest.java | 0 .../rimuhosting/src/test/resources/cancelled.json | 0 .../rimuhosting/src/test/resources/log4j.xml | 0 70 files changed, 8 insertions(+), 2 deletions(-) rename {sandbox-providers => providers}/rimuhosting/README.txt (100%) rename {sandbox-providers => providers}/rimuhosting/pom.xml (100%) rename {sandbox-providers => providers}/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/RimuHostingAsyncClient.java (100%) rename {sandbox-providers => providers}/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/RimuHostingClient.java (100%) rename {sandbox-providers => providers}/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/RimuHostingContextBuilder.java (100%) rename {sandbox-providers => providers}/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/RimuHostingPropertiesBuilder.java (100%) rename {sandbox-providers => providers}/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/binder/CreateServerOptions.java (100%) rename {sandbox-providers => providers}/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/binder/RimuHostingJsonBinder.java (100%) rename {sandbox-providers => providers}/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/binder/RimuHostingRebootJsonBinder.java (100%) rename {sandbox-providers => providers}/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/compute/config/RimuHostingBindComputeStrategiesByClass.java (100%) rename {sandbox-providers => providers}/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/compute/config/RimuHostingBindComputeSuppliersByClass.java (100%) rename {sandbox-providers => providers}/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/compute/config/RimuHostingComputeServiceContextModule.java (100%) rename {sandbox-providers => providers}/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/compute/config/RimuHostingComputeServiceDependenciesModule.java (100%) rename {sandbox-providers => providers}/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/compute/functions/ServerToNodeMetadata.java (100%) rename {sandbox-providers => providers}/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/compute/strategy/RimuHostingCreateNodeWithGroupEncodedIntoName.java (100%) rename {sandbox-providers => providers}/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/compute/strategy/RimuHostingDestroyNodeStrategy.java (100%) rename {sandbox-providers => providers}/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/compute/strategy/RimuHostingGetNodeMetadataStrategy.java (100%) rename {sandbox-providers => providers}/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/compute/strategy/RimuHostingLifeCycleStrategy.java (100%) rename {sandbox-providers => providers}/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/compute/strategy/RimuHostingListNodesStrategy.java (100%) rename {sandbox-providers => providers}/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/compute/suppliers/RimuHostingDefaultLocationSupplier.java (100%) rename {sandbox-providers => providers}/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/compute/suppliers/RimuHostingHardwareSupplier.java (100%) rename {sandbox-providers => providers}/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/compute/suppliers/RimuHostingImageSupplier.java (100%) rename {sandbox-providers => providers}/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/compute/suppliers/RimuHostingLocationSupplier.java (100%) rename {sandbox-providers => providers}/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/config/RimuHostingRestClientModule.java (100%) rename {sandbox-providers => providers}/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/data/CloneOptions.java (100%) rename {sandbox-providers => providers}/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/data/CreateOptions.java (100%) rename {sandbox-providers => providers}/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/data/IpRequestData.java (100%) rename {sandbox-providers => providers}/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/data/NewServerData.java (100%) rename {sandbox-providers => providers}/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/data/PostData.java (100%) rename {sandbox-providers => providers}/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/domain/BillingData.java (100%) rename {sandbox-providers => providers}/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/domain/DataCenter.java (100%) rename {sandbox-providers => providers}/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/domain/DataTransferAllowance.java (100%) rename {sandbox-providers => providers}/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/domain/Image.java (100%) rename {sandbox-providers => providers}/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/domain/IpAddresses.java (100%) rename {sandbox-providers => providers}/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/domain/MetaData.java (100%) rename {sandbox-providers => providers}/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/domain/NewServerResponse.java (100%) rename {sandbox-providers => providers}/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/domain/PricingPlan.java (100%) rename {sandbox-providers => providers}/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/domain/ResizeResponse.java (100%) rename {sandbox-providers => providers}/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/domain/ResizeResult.java (100%) rename {sandbox-providers => providers}/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/domain/Server.java (100%) rename {sandbox-providers => providers}/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/domain/ServerInfo.java (100%) rename {sandbox-providers => providers}/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/domain/ServerParameters.java (100%) rename {sandbox-providers => providers}/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/domain/internal/RimuHostingError.java (100%) rename {sandbox-providers => providers}/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/domain/internal/RimuHostingResponse.java (100%) rename {sandbox-providers => providers}/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/domain/internal/RimuHostingTimestamp.java (100%) rename {sandbox-providers => providers}/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/domain/internal/RunningState.java (100%) rename {sandbox-providers => providers}/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/domain/internal/ServerType.java (100%) rename {sandbox-providers => providers}/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/filters/RimuHostingAuthentication.java (100%) rename {sandbox-providers => providers}/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/functions/ParseDestroyResponseFromJsonResponse.java (100%) rename {sandbox-providers => providers}/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/functions/ParseImagesFromJsonResponse.java (100%) rename {sandbox-providers => providers}/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/functions/ParsePricingPlansFromJsonResponse.java (100%) rename {sandbox-providers => providers}/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/functions/ParseRimuHostingException.java (100%) rename {sandbox-providers => providers}/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/functions/ParseServerFromJsonResponse.java (100%) rename {sandbox-providers => providers}/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/functions/ParseServerInfoFromJsonResponse.java (100%) rename {sandbox-providers => providers}/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/functions/ParseServersFromJsonResponse.java (100%) rename {sandbox-providers => providers}/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/predicates/ServerDestroyed.java (100%) rename {sandbox-providers => providers}/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/predicates/ServerRunning.java (100%) rename {sandbox-providers => providers}/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/reference/RimuHostingConstants.java (100%) rename {sandbox-providers => providers}/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/ProvidersInPropertiesTest.java (100%) rename {sandbox-providers => providers}/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/RimuHostingAsyncClientTest.java (100%) rename {sandbox-providers => providers}/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/RimuHostingClientLiveTest.java (100%) rename {sandbox-providers => providers}/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/compute/RimuHostingComputeServiceLiveTest.java (100%) rename {sandbox-providers => providers}/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/compute/RimuHostingTemplateBuilderLiveTest.java (100%) rename {sandbox-providers => providers}/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/compute/config/RimuHostingComputeServiceContextModuleTest.java (100%) rename {sandbox-providers => providers}/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/functions/ParseServerFromJsonResponseTest.java (100%) rename {sandbox-providers => providers}/rimuhosting/src/test/resources/cancelled.json (100%) rename {sandbox-providers => providers}/rimuhosting/src/test/resources/log4j.xml (100%) diff --git a/README.txt b/README.txt index 89c1dd96a5..44a5a78f0c 100644 --- a/README.txt +++ b/README.txt @@ -33,7 +33,7 @@ our compute api supports: aws-ec2, gogrid, cloudservers-us, stub (in-memory), de cloudservers-uk, vcloud (generic), ec2 (generic), byon, nova, trmk-ecloud, trmk-vcloudexpress, eucalyptus (generic), cloudsigma-zrh, elasticstack(generic), bluelock-vcloud-vcenterprise, - bluelock-vcloud-zone01, stratogen-vcloud-mycloud, + bluelock-vcloud-zone01, stratogen-vcloud-mycloud, rimuhosting, slicehost, eucalyptus-partnercloud-ec2, elastichosts-lon-p (Peer 1), elastichosts-sat-p (Peer 1), elastichosts-lon-b (BlueSquare), openhosting-east1, serverlove-z1-man, skalicloud-sdg-my @@ -55,7 +55,7 @@ our loadbalancer api supports: cloudloadbalancers-us * note * the pom dependency org.jclouds/jclouds-allloadbalancer gives you access to to all of these providers -we also have support for: ibmdev, mezeo, nirvanix, boxdotnet, rimuhosting, openstack nova, +we also have support for: ibmdev, mezeo, nirvanix, boxdotnet, openstack nova, azurequeue, simpledb, cloudstack as well as a async-http-client driver in the sandbox diff --git a/allcompute/pom.xml b/allcompute/pom.xml index f1a130039f..c032904840 100644 --- a/allcompute/pom.xml +++ b/allcompute/pom.xml @@ -49,6 +49,11 @@ aws-ec2 ${project.version} + + org.jclouds.provider + rimuhosting + ${project.version} + org.jclouds.api nova diff --git a/providers/pom.xml b/providers/pom.xml index 91ba5d6a15..5db5034f4d 100644 --- a/providers/pom.xml +++ b/providers/pom.xml @@ -62,6 +62,7 @@ elastichosts-lon-p elastichosts-sat-p elastichosts-lon-b + rimuhosting openhosting-east1 serverlove-z1-man skalicloud-sdg-my diff --git a/sandbox-providers/rimuhosting/README.txt b/providers/rimuhosting/README.txt similarity index 100% rename from sandbox-providers/rimuhosting/README.txt rename to providers/rimuhosting/README.txt diff --git a/sandbox-providers/rimuhosting/pom.xml b/providers/rimuhosting/pom.xml similarity index 100% rename from sandbox-providers/rimuhosting/pom.xml rename to providers/rimuhosting/pom.xml diff --git a/sandbox-providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/RimuHostingAsyncClient.java b/providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/RimuHostingAsyncClient.java similarity index 100% rename from sandbox-providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/RimuHostingAsyncClient.java rename to providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/RimuHostingAsyncClient.java diff --git a/sandbox-providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/RimuHostingClient.java b/providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/RimuHostingClient.java similarity index 100% rename from sandbox-providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/RimuHostingClient.java rename to providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/RimuHostingClient.java diff --git a/sandbox-providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/RimuHostingContextBuilder.java b/providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/RimuHostingContextBuilder.java similarity index 100% rename from sandbox-providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/RimuHostingContextBuilder.java rename to providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/RimuHostingContextBuilder.java diff --git a/sandbox-providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/RimuHostingPropertiesBuilder.java b/providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/RimuHostingPropertiesBuilder.java similarity index 100% rename from sandbox-providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/RimuHostingPropertiesBuilder.java rename to providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/RimuHostingPropertiesBuilder.java diff --git a/sandbox-providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/binder/CreateServerOptions.java b/providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/binder/CreateServerOptions.java similarity index 100% rename from sandbox-providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/binder/CreateServerOptions.java rename to providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/binder/CreateServerOptions.java diff --git a/sandbox-providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/binder/RimuHostingJsonBinder.java b/providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/binder/RimuHostingJsonBinder.java similarity index 100% rename from sandbox-providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/binder/RimuHostingJsonBinder.java rename to providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/binder/RimuHostingJsonBinder.java diff --git a/sandbox-providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/binder/RimuHostingRebootJsonBinder.java b/providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/binder/RimuHostingRebootJsonBinder.java similarity index 100% rename from sandbox-providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/binder/RimuHostingRebootJsonBinder.java rename to providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/binder/RimuHostingRebootJsonBinder.java diff --git a/sandbox-providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/compute/config/RimuHostingBindComputeStrategiesByClass.java b/providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/compute/config/RimuHostingBindComputeStrategiesByClass.java similarity index 100% rename from sandbox-providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/compute/config/RimuHostingBindComputeStrategiesByClass.java rename to providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/compute/config/RimuHostingBindComputeStrategiesByClass.java diff --git a/sandbox-providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/compute/config/RimuHostingBindComputeSuppliersByClass.java b/providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/compute/config/RimuHostingBindComputeSuppliersByClass.java similarity index 100% rename from sandbox-providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/compute/config/RimuHostingBindComputeSuppliersByClass.java rename to providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/compute/config/RimuHostingBindComputeSuppliersByClass.java diff --git a/sandbox-providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/compute/config/RimuHostingComputeServiceContextModule.java b/providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/compute/config/RimuHostingComputeServiceContextModule.java similarity index 100% rename from sandbox-providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/compute/config/RimuHostingComputeServiceContextModule.java rename to providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/compute/config/RimuHostingComputeServiceContextModule.java diff --git a/sandbox-providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/compute/config/RimuHostingComputeServiceDependenciesModule.java b/providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/compute/config/RimuHostingComputeServiceDependenciesModule.java similarity index 100% rename from sandbox-providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/compute/config/RimuHostingComputeServiceDependenciesModule.java rename to providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/compute/config/RimuHostingComputeServiceDependenciesModule.java diff --git a/sandbox-providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/compute/functions/ServerToNodeMetadata.java b/providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/compute/functions/ServerToNodeMetadata.java similarity index 100% rename from sandbox-providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/compute/functions/ServerToNodeMetadata.java rename to providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/compute/functions/ServerToNodeMetadata.java diff --git a/sandbox-providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/compute/strategy/RimuHostingCreateNodeWithGroupEncodedIntoName.java b/providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/compute/strategy/RimuHostingCreateNodeWithGroupEncodedIntoName.java similarity index 100% rename from sandbox-providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/compute/strategy/RimuHostingCreateNodeWithGroupEncodedIntoName.java rename to providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/compute/strategy/RimuHostingCreateNodeWithGroupEncodedIntoName.java diff --git a/sandbox-providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/compute/strategy/RimuHostingDestroyNodeStrategy.java b/providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/compute/strategy/RimuHostingDestroyNodeStrategy.java similarity index 100% rename from sandbox-providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/compute/strategy/RimuHostingDestroyNodeStrategy.java rename to providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/compute/strategy/RimuHostingDestroyNodeStrategy.java diff --git a/sandbox-providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/compute/strategy/RimuHostingGetNodeMetadataStrategy.java b/providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/compute/strategy/RimuHostingGetNodeMetadataStrategy.java similarity index 100% rename from sandbox-providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/compute/strategy/RimuHostingGetNodeMetadataStrategy.java rename to providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/compute/strategy/RimuHostingGetNodeMetadataStrategy.java diff --git a/sandbox-providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/compute/strategy/RimuHostingLifeCycleStrategy.java b/providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/compute/strategy/RimuHostingLifeCycleStrategy.java similarity index 100% rename from sandbox-providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/compute/strategy/RimuHostingLifeCycleStrategy.java rename to providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/compute/strategy/RimuHostingLifeCycleStrategy.java diff --git a/sandbox-providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/compute/strategy/RimuHostingListNodesStrategy.java b/providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/compute/strategy/RimuHostingListNodesStrategy.java similarity index 100% rename from sandbox-providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/compute/strategy/RimuHostingListNodesStrategy.java rename to providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/compute/strategy/RimuHostingListNodesStrategy.java diff --git a/sandbox-providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/compute/suppliers/RimuHostingDefaultLocationSupplier.java b/providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/compute/suppliers/RimuHostingDefaultLocationSupplier.java similarity index 100% rename from sandbox-providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/compute/suppliers/RimuHostingDefaultLocationSupplier.java rename to providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/compute/suppliers/RimuHostingDefaultLocationSupplier.java diff --git a/sandbox-providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/compute/suppliers/RimuHostingHardwareSupplier.java b/providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/compute/suppliers/RimuHostingHardwareSupplier.java similarity index 100% rename from sandbox-providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/compute/suppliers/RimuHostingHardwareSupplier.java rename to providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/compute/suppliers/RimuHostingHardwareSupplier.java diff --git a/sandbox-providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/compute/suppliers/RimuHostingImageSupplier.java b/providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/compute/suppliers/RimuHostingImageSupplier.java similarity index 100% rename from sandbox-providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/compute/suppliers/RimuHostingImageSupplier.java rename to providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/compute/suppliers/RimuHostingImageSupplier.java diff --git a/sandbox-providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/compute/suppliers/RimuHostingLocationSupplier.java b/providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/compute/suppliers/RimuHostingLocationSupplier.java similarity index 100% rename from sandbox-providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/compute/suppliers/RimuHostingLocationSupplier.java rename to providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/compute/suppliers/RimuHostingLocationSupplier.java diff --git a/sandbox-providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/config/RimuHostingRestClientModule.java b/providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/config/RimuHostingRestClientModule.java similarity index 100% rename from sandbox-providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/config/RimuHostingRestClientModule.java rename to providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/config/RimuHostingRestClientModule.java diff --git a/sandbox-providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/data/CloneOptions.java b/providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/data/CloneOptions.java similarity index 100% rename from sandbox-providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/data/CloneOptions.java rename to providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/data/CloneOptions.java diff --git a/sandbox-providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/data/CreateOptions.java b/providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/data/CreateOptions.java similarity index 100% rename from sandbox-providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/data/CreateOptions.java rename to providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/data/CreateOptions.java diff --git a/sandbox-providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/data/IpRequestData.java b/providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/data/IpRequestData.java similarity index 100% rename from sandbox-providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/data/IpRequestData.java rename to providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/data/IpRequestData.java diff --git a/sandbox-providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/data/NewServerData.java b/providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/data/NewServerData.java similarity index 100% rename from sandbox-providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/data/NewServerData.java rename to providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/data/NewServerData.java diff --git a/sandbox-providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/data/PostData.java b/providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/data/PostData.java similarity index 100% rename from sandbox-providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/data/PostData.java rename to providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/data/PostData.java diff --git a/sandbox-providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/domain/BillingData.java b/providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/domain/BillingData.java similarity index 100% rename from sandbox-providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/domain/BillingData.java rename to providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/domain/BillingData.java diff --git a/sandbox-providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/domain/DataCenter.java b/providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/domain/DataCenter.java similarity index 100% rename from sandbox-providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/domain/DataCenter.java rename to providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/domain/DataCenter.java diff --git a/sandbox-providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/domain/DataTransferAllowance.java b/providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/domain/DataTransferAllowance.java similarity index 100% rename from sandbox-providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/domain/DataTransferAllowance.java rename to providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/domain/DataTransferAllowance.java diff --git a/sandbox-providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/domain/Image.java b/providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/domain/Image.java similarity index 100% rename from sandbox-providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/domain/Image.java rename to providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/domain/Image.java diff --git a/sandbox-providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/domain/IpAddresses.java b/providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/domain/IpAddresses.java similarity index 100% rename from sandbox-providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/domain/IpAddresses.java rename to providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/domain/IpAddresses.java diff --git a/sandbox-providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/domain/MetaData.java b/providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/domain/MetaData.java similarity index 100% rename from sandbox-providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/domain/MetaData.java rename to providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/domain/MetaData.java diff --git a/sandbox-providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/domain/NewServerResponse.java b/providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/domain/NewServerResponse.java similarity index 100% rename from sandbox-providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/domain/NewServerResponse.java rename to providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/domain/NewServerResponse.java diff --git a/sandbox-providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/domain/PricingPlan.java b/providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/domain/PricingPlan.java similarity index 100% rename from sandbox-providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/domain/PricingPlan.java rename to providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/domain/PricingPlan.java diff --git a/sandbox-providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/domain/ResizeResponse.java b/providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/domain/ResizeResponse.java similarity index 100% rename from sandbox-providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/domain/ResizeResponse.java rename to providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/domain/ResizeResponse.java diff --git a/sandbox-providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/domain/ResizeResult.java b/providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/domain/ResizeResult.java similarity index 100% rename from sandbox-providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/domain/ResizeResult.java rename to providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/domain/ResizeResult.java diff --git a/sandbox-providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/domain/Server.java b/providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/domain/Server.java similarity index 100% rename from sandbox-providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/domain/Server.java rename to providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/domain/Server.java diff --git a/sandbox-providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/domain/ServerInfo.java b/providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/domain/ServerInfo.java similarity index 100% rename from sandbox-providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/domain/ServerInfo.java rename to providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/domain/ServerInfo.java diff --git a/sandbox-providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/domain/ServerParameters.java b/providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/domain/ServerParameters.java similarity index 100% rename from sandbox-providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/domain/ServerParameters.java rename to providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/domain/ServerParameters.java diff --git a/sandbox-providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/domain/internal/RimuHostingError.java b/providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/domain/internal/RimuHostingError.java similarity index 100% rename from sandbox-providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/domain/internal/RimuHostingError.java rename to providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/domain/internal/RimuHostingError.java diff --git a/sandbox-providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/domain/internal/RimuHostingResponse.java b/providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/domain/internal/RimuHostingResponse.java similarity index 100% rename from sandbox-providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/domain/internal/RimuHostingResponse.java rename to providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/domain/internal/RimuHostingResponse.java diff --git a/sandbox-providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/domain/internal/RimuHostingTimestamp.java b/providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/domain/internal/RimuHostingTimestamp.java similarity index 100% rename from sandbox-providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/domain/internal/RimuHostingTimestamp.java rename to providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/domain/internal/RimuHostingTimestamp.java diff --git a/sandbox-providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/domain/internal/RunningState.java b/providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/domain/internal/RunningState.java similarity index 100% rename from sandbox-providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/domain/internal/RunningState.java rename to providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/domain/internal/RunningState.java diff --git a/sandbox-providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/domain/internal/ServerType.java b/providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/domain/internal/ServerType.java similarity index 100% rename from sandbox-providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/domain/internal/ServerType.java rename to providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/domain/internal/ServerType.java diff --git a/sandbox-providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/filters/RimuHostingAuthentication.java b/providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/filters/RimuHostingAuthentication.java similarity index 100% rename from sandbox-providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/filters/RimuHostingAuthentication.java rename to providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/filters/RimuHostingAuthentication.java diff --git a/sandbox-providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/functions/ParseDestroyResponseFromJsonResponse.java b/providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/functions/ParseDestroyResponseFromJsonResponse.java similarity index 100% rename from sandbox-providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/functions/ParseDestroyResponseFromJsonResponse.java rename to providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/functions/ParseDestroyResponseFromJsonResponse.java diff --git a/sandbox-providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/functions/ParseImagesFromJsonResponse.java b/providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/functions/ParseImagesFromJsonResponse.java similarity index 100% rename from sandbox-providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/functions/ParseImagesFromJsonResponse.java rename to providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/functions/ParseImagesFromJsonResponse.java diff --git a/sandbox-providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/functions/ParsePricingPlansFromJsonResponse.java b/providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/functions/ParsePricingPlansFromJsonResponse.java similarity index 100% rename from sandbox-providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/functions/ParsePricingPlansFromJsonResponse.java rename to providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/functions/ParsePricingPlansFromJsonResponse.java diff --git a/sandbox-providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/functions/ParseRimuHostingException.java b/providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/functions/ParseRimuHostingException.java similarity index 100% rename from sandbox-providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/functions/ParseRimuHostingException.java rename to providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/functions/ParseRimuHostingException.java diff --git a/sandbox-providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/functions/ParseServerFromJsonResponse.java b/providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/functions/ParseServerFromJsonResponse.java similarity index 100% rename from sandbox-providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/functions/ParseServerFromJsonResponse.java rename to providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/functions/ParseServerFromJsonResponse.java diff --git a/sandbox-providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/functions/ParseServerInfoFromJsonResponse.java b/providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/functions/ParseServerInfoFromJsonResponse.java similarity index 100% rename from sandbox-providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/functions/ParseServerInfoFromJsonResponse.java rename to providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/functions/ParseServerInfoFromJsonResponse.java diff --git a/sandbox-providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/functions/ParseServersFromJsonResponse.java b/providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/functions/ParseServersFromJsonResponse.java similarity index 100% rename from sandbox-providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/functions/ParseServersFromJsonResponse.java rename to providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/functions/ParseServersFromJsonResponse.java diff --git a/sandbox-providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/predicates/ServerDestroyed.java b/providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/predicates/ServerDestroyed.java similarity index 100% rename from sandbox-providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/predicates/ServerDestroyed.java rename to providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/predicates/ServerDestroyed.java diff --git a/sandbox-providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/predicates/ServerRunning.java b/providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/predicates/ServerRunning.java similarity index 100% rename from sandbox-providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/predicates/ServerRunning.java rename to providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/predicates/ServerRunning.java diff --git a/sandbox-providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/reference/RimuHostingConstants.java b/providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/reference/RimuHostingConstants.java similarity index 100% rename from sandbox-providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/reference/RimuHostingConstants.java rename to providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/reference/RimuHostingConstants.java diff --git a/sandbox-providers/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/ProvidersInPropertiesTest.java b/providers/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/ProvidersInPropertiesTest.java similarity index 100% rename from sandbox-providers/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/ProvidersInPropertiesTest.java rename to providers/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/ProvidersInPropertiesTest.java diff --git a/sandbox-providers/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/RimuHostingAsyncClientTest.java b/providers/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/RimuHostingAsyncClientTest.java similarity index 100% rename from sandbox-providers/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/RimuHostingAsyncClientTest.java rename to providers/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/RimuHostingAsyncClientTest.java diff --git a/sandbox-providers/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/RimuHostingClientLiveTest.java b/providers/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/RimuHostingClientLiveTest.java similarity index 100% rename from sandbox-providers/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/RimuHostingClientLiveTest.java rename to providers/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/RimuHostingClientLiveTest.java diff --git a/sandbox-providers/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/compute/RimuHostingComputeServiceLiveTest.java b/providers/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/compute/RimuHostingComputeServiceLiveTest.java similarity index 100% rename from sandbox-providers/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/compute/RimuHostingComputeServiceLiveTest.java rename to providers/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/compute/RimuHostingComputeServiceLiveTest.java diff --git a/sandbox-providers/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/compute/RimuHostingTemplateBuilderLiveTest.java b/providers/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/compute/RimuHostingTemplateBuilderLiveTest.java similarity index 100% rename from sandbox-providers/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/compute/RimuHostingTemplateBuilderLiveTest.java rename to providers/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/compute/RimuHostingTemplateBuilderLiveTest.java diff --git a/sandbox-providers/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/compute/config/RimuHostingComputeServiceContextModuleTest.java b/providers/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/compute/config/RimuHostingComputeServiceContextModuleTest.java similarity index 100% rename from sandbox-providers/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/compute/config/RimuHostingComputeServiceContextModuleTest.java rename to providers/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/compute/config/RimuHostingComputeServiceContextModuleTest.java diff --git a/sandbox-providers/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/functions/ParseServerFromJsonResponseTest.java b/providers/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/functions/ParseServerFromJsonResponseTest.java similarity index 100% rename from sandbox-providers/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/functions/ParseServerFromJsonResponseTest.java rename to providers/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/functions/ParseServerFromJsonResponseTest.java diff --git a/sandbox-providers/rimuhosting/src/test/resources/cancelled.json b/providers/rimuhosting/src/test/resources/cancelled.json similarity index 100% rename from sandbox-providers/rimuhosting/src/test/resources/cancelled.json rename to providers/rimuhosting/src/test/resources/cancelled.json diff --git a/sandbox-providers/rimuhosting/src/test/resources/log4j.xml b/providers/rimuhosting/src/test/resources/log4j.xml similarity index 100% rename from sandbox-providers/rimuhosting/src/test/resources/log4j.xml rename to providers/rimuhosting/src/test/resources/log4j.xml From 563462e46bebea010d11144bd5d6a2249e5c6b28 Mon Sep 17 00:00:00 2001 From: Kedar Dave Date: Thu, 2 Jun 2011 18:23:08 -0500 Subject: [PATCH 032/264] added providermetadata test for savvis-symphonyvpdc --- .../org.jclouds.providers.ProviderMetadata | 1 + .../vpdc/SavvisSymphonyVPDCProviderTest.java | 36 +++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 providers/savvis-symphonyvpdc/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata create mode 100644 providers/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/SavvisSymphonyVPDCProviderTest.java diff --git a/providers/savvis-symphonyvpdc/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata b/providers/savvis-symphonyvpdc/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata new file mode 100644 index 0000000000..ab54604528 --- /dev/null +++ b/providers/savvis-symphonyvpdc/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata @@ -0,0 +1 @@ +org.jclouds.savvis.vpdc.SavvisSymphonyVPDCProviderMetadata \ No newline at end of file diff --git a/providers/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/SavvisSymphonyVPDCProviderTest.java b/providers/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/SavvisSymphonyVPDCProviderTest.java new file mode 100644 index 0000000000..1cb30f9ece --- /dev/null +++ b/providers/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/SavvisSymphonyVPDCProviderTest.java @@ -0,0 +1,36 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.jclouds.savvis.vpdc; + +import org.jclouds.providers.BaseProviderMetadataTest; +import org.jclouds.providers.ProviderMetadata; +import org.testng.annotations.Test; + +/** + * The SavvisSymphonyVPDCProviderTest tests the org.jclouds.savvis.vpdc.SavvisSymphonyVPDCProviderMetadata class. + * + * @author Kedar Dave + */ +@Test(groups = "unit", testName = "SavvisSymphonyVPDCProviderTest") +public class SavvisSymphonyVPDCProviderTest extends BaseProviderMetadataTest { + + public SavvisSymphonyVPDCProviderTest() { + super(new SavvisSymphonyVPDCProviderMetadata(), ProviderMetadata.COMPUTE_TYPE); + } +} \ No newline at end of file From e29e9cd4a36a2937a36c792101c4296ea124febd Mon Sep 17 00:00:00 2001 From: Dmitri Babaev Date: Fri, 3 Jun 2011 03:38:40 +0400 Subject: [PATCH 033/264] non-working live tests is disabled (they are not working due to the issues with OpenStack) --- .../openstack/nova/live/novaclient/NovaClientLiveTest.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/apis/nova/src/test/java/org/jclouds/openstack/nova/live/novaclient/NovaClientLiveTest.java b/apis/nova/src/test/java/org/jclouds/openstack/nova/live/novaclient/NovaClientLiveTest.java index 0c149fe4f9..968ac05bee 100644 --- a/apis/nova/src/test/java/org/jclouds/openstack/nova/live/novaclient/NovaClientLiveTest.java +++ b/apis/nova/src/test/java/org/jclouds/openstack/nova/live/novaclient/NovaClientLiveTest.java @@ -55,9 +55,8 @@ public class NovaClientLiveTest extends ClientBase { assertTrue(initialContainerCount >= 0); } - @Test(enabled = false) + @Test public void testListServersDetail() throws Exception { - //TODO: failing, /v1.1/servers/{server id}/ips URL is not available (issue in the OpenStack) Set response = client.listServers(withDetails()); assert null != response; long initialContainerCount = response.size(); @@ -229,8 +228,9 @@ public class NovaClientLiveTest extends ClientBase { } } - @Test(enabled = true, timeOut = 300000) + @Test(enabled = false, timeOut = 300000) public void testServerDetails() throws Exception { + //TODO: failing, /v1.1/servers/{server id}/ips URL is not available (issue in the OpenStack) Server server = getDefaultServerImmediately(); assertNotNull(server.getHostId(), "Host id: "); assertNotNull(server.getAddresses()); From 461f49622d45dc6db429583135241eb9f943ccf3 Mon Sep 17 00:00:00 2001 From: Adrian Cole Date: Thu, 2 Jun 2011 16:52:28 -0700 Subject: [PATCH 034/264] moved scality rs2 services into sandbox due to service problems --- README.txt | 6 +++--- allblobstore/pom.xml | 20 ------------------- apis/pom.xml | 1 - providers/pom.xml | 3 --- {apis => sandbox-apis}/scality-rs2/README.txt | 0 {apis => sandbox-apis}/scality-rs2/pom.xml | 0 .../scality/rs2/ScalityRS2AsyncClient.java | 0 .../scality/rs2/ScalityRS2ContextBuilder.java | 0 .../rs2/ScalityRS2PropertiesBuilder.java | 0 .../ScalityRS2BlobStoreContextModule.java | 0 .../config/ScalityRS2RestClientModule.java | 0 .../ScalityRS2AsyncClientTestDisabled.java | 0 .../scality/rs2/ScalityRS2ClientLiveTest.java | 0 .../ScalityRS2BlobIntegrationLiveTest.java | 0 .../rs2/blobstore/ScalityRS2BlobLiveTest.java | 0 .../ScalityRS2BlobMapIntegrationLiveTest.java | 0 .../ScalityRS2BlobSignerLiveTest.java | 0 ...calityRS2ContainerIntegrationLiveTest.java | 0 .../ScalityRS2ContainerLiveTest.java | 0 ...yRS2InputStreamMapIntegrationLiveTest.java | 0 .../ScalityRS2ServiceIntegrationLiveTest.java | 0 .../blobstore/ScalityRS2TestInitializer.java | 0 .../hosteurope-storage/pom.xml | 0 .../HostEuropeStoragePropertiesBuilder.java | 0 .../HostEuropeStorageClientLiveTest.java | 0 ...tEuropeStorageBlobIntegrationLiveTest.java | 0 .../HostEuropeStorageBlobLiveTest.java | 0 ...ropeStorageBlobMapIntegrationLiveTest.java | 0 .../HostEuropeStorageBlobSignerLiveTest.java | 0 ...peStorageContainerIntegrationLiveTest.java | 0 .../HostEuropeStorageContainerLiveTest.java | 0 ...rageInputStreamMapIntegrationLiveTest.java | 0 ...ropeStorageServiceIntegrationLiveTest.java | 0 .../HostEuropeStorageTestInitializer.java | 0 .../scaleup-storage/README.txt | 0 .../scaleup-storage/pom.xml | 0 .../ScaleUpStoragePropertiesBuilder.java | 0 .../storage/ScaleUpStorageClientLiveTest.java | 0 ...ScaleUpStorageBlobIntegrationLiveTest.java | 0 .../blobstore/ScaleUpStorageBlobLiveTest.java | 0 ...leUpStorageBlobMapIntegrationLiveTest.java | 0 .../ScaleUpStorageBlobSignerLiveTest.java | 0 ...UpStorageContainerIntegrationLiveTest.java | 0 .../ScaleUpStorageContainerLiveTest.java | 0 ...rageInputStreamMapIntegrationLiveTest.java | 0 ...leUpStorageServiceIntegrationLiveTest.java | 0 .../ScaleUpStorageTestInitializer.java | 0 .../tiscali-storage/pom.xml | 0 .../TiscaliStoragePropertiesBuilder.java | 0 .../storage/TiscaliStorageClientLiveTest.java | 0 ...TiscaliStorageBlobIntegrationLiveTest.java | 0 .../blobstore/TiscaliStorageBlobLiveTest.java | 0 ...caliStorageBlobMapIntegrationLiveTest.java | 0 .../TiscaliStorageBlobSignerLiveTest.java | 0 ...liStorageContainerIntegrationLiveTest.java | 0 .../TiscaliStorageContainerLiveTest.java | 0 ...rageInputStreamMapIntegrationLiveTest.java | 0 ...caliStorageServiceIntegrationLiveTest.java | 0 .../TiscaliStorageTestInitializer.java | 0 59 files changed, 3 insertions(+), 27 deletions(-) rename {apis => sandbox-apis}/scality-rs2/README.txt (100%) rename {apis => sandbox-apis}/scality-rs2/pom.xml (100%) rename {apis => sandbox-apis}/scality-rs2/src/main/java/org/jclouds/scality/rs2/ScalityRS2AsyncClient.java (100%) rename {apis => sandbox-apis}/scality-rs2/src/main/java/org/jclouds/scality/rs2/ScalityRS2ContextBuilder.java (100%) rename {apis => sandbox-apis}/scality-rs2/src/main/java/org/jclouds/scality/rs2/ScalityRS2PropertiesBuilder.java (100%) rename {apis => sandbox-apis}/scality-rs2/src/main/java/org/jclouds/scality/rs2/blobstore/config/ScalityRS2BlobStoreContextModule.java (100%) rename {apis => sandbox-apis}/scality-rs2/src/main/java/org/jclouds/scality/rs2/config/ScalityRS2RestClientModule.java (100%) rename {apis => sandbox-apis}/scality-rs2/src/test/java/org/jclouds/scality/rs2/ScalityRS2AsyncClientTestDisabled.java (100%) rename {apis => sandbox-apis}/scality-rs2/src/test/java/org/jclouds/scality/rs2/ScalityRS2ClientLiveTest.java (100%) rename {apis => sandbox-apis}/scality-rs2/src/test/java/org/jclouds/scality/rs2/blobstore/ScalityRS2BlobIntegrationLiveTest.java (100%) rename {apis => sandbox-apis}/scality-rs2/src/test/java/org/jclouds/scality/rs2/blobstore/ScalityRS2BlobLiveTest.java (100%) rename {apis => sandbox-apis}/scality-rs2/src/test/java/org/jclouds/scality/rs2/blobstore/ScalityRS2BlobMapIntegrationLiveTest.java (100%) rename {apis => sandbox-apis}/scality-rs2/src/test/java/org/jclouds/scality/rs2/blobstore/ScalityRS2BlobSignerLiveTest.java (100%) rename {apis => sandbox-apis}/scality-rs2/src/test/java/org/jclouds/scality/rs2/blobstore/ScalityRS2ContainerIntegrationLiveTest.java (100%) rename {apis => sandbox-apis}/scality-rs2/src/test/java/org/jclouds/scality/rs2/blobstore/ScalityRS2ContainerLiveTest.java (100%) rename {apis => sandbox-apis}/scality-rs2/src/test/java/org/jclouds/scality/rs2/blobstore/ScalityRS2InputStreamMapIntegrationLiveTest.java (100%) rename {apis => sandbox-apis}/scality-rs2/src/test/java/org/jclouds/scality/rs2/blobstore/ScalityRS2ServiceIntegrationLiveTest.java (100%) rename {apis => sandbox-apis}/scality-rs2/src/test/java/org/jclouds/scality/rs2/blobstore/ScalityRS2TestInitializer.java (100%) rename {providers => sandbox-providers}/hosteurope-storage/pom.xml (100%) rename {providers => sandbox-providers}/hosteurope-storage/src/main/java/org/jclouds/hosteurope/storage/HostEuropeStoragePropertiesBuilder.java (100%) rename {providers => sandbox-providers}/hosteurope-storage/src/test/java/org/jclouds/hosteurope/storage/HostEuropeStorageClientLiveTest.java (100%) rename {providers => sandbox-providers}/hosteurope-storage/src/test/java/org/jclouds/hosteurope/storage/blobstore/HostEuropeStorageBlobIntegrationLiveTest.java (100%) rename {providers => sandbox-providers}/hosteurope-storage/src/test/java/org/jclouds/hosteurope/storage/blobstore/HostEuropeStorageBlobLiveTest.java (100%) rename {providers => sandbox-providers}/hosteurope-storage/src/test/java/org/jclouds/hosteurope/storage/blobstore/HostEuropeStorageBlobMapIntegrationLiveTest.java (100%) rename {providers => sandbox-providers}/hosteurope-storage/src/test/java/org/jclouds/hosteurope/storage/blobstore/HostEuropeStorageBlobSignerLiveTest.java (100%) rename {providers => sandbox-providers}/hosteurope-storage/src/test/java/org/jclouds/hosteurope/storage/blobstore/HostEuropeStorageContainerIntegrationLiveTest.java (100%) rename {providers => sandbox-providers}/hosteurope-storage/src/test/java/org/jclouds/hosteurope/storage/blobstore/HostEuropeStorageContainerLiveTest.java (100%) rename {providers => sandbox-providers}/hosteurope-storage/src/test/java/org/jclouds/hosteurope/storage/blobstore/HostEuropeStorageInputStreamMapIntegrationLiveTest.java (100%) rename {providers => sandbox-providers}/hosteurope-storage/src/test/java/org/jclouds/hosteurope/storage/blobstore/HostEuropeStorageServiceIntegrationLiveTest.java (100%) rename {providers => sandbox-providers}/hosteurope-storage/src/test/java/org/jclouds/hosteurope/storage/blobstore/HostEuropeStorageTestInitializer.java (100%) rename {providers => sandbox-providers}/scaleup-storage/README.txt (100%) rename {providers => sandbox-providers}/scaleup-storage/pom.xml (100%) rename {providers => sandbox-providers}/scaleup-storage/src/main/java/org/jclouds/scaleup/storage/ScaleUpStoragePropertiesBuilder.java (100%) rename {providers => sandbox-providers}/scaleup-storage/src/test/java/org/jclouds/scaleup/storage/ScaleUpStorageClientLiveTest.java (100%) rename {providers => sandbox-providers}/scaleup-storage/src/test/java/org/jclouds/scaleup/storage/blobstore/ScaleUpStorageBlobIntegrationLiveTest.java (100%) rename {providers => sandbox-providers}/scaleup-storage/src/test/java/org/jclouds/scaleup/storage/blobstore/ScaleUpStorageBlobLiveTest.java (100%) rename {providers => sandbox-providers}/scaleup-storage/src/test/java/org/jclouds/scaleup/storage/blobstore/ScaleUpStorageBlobMapIntegrationLiveTest.java (100%) rename {providers => sandbox-providers}/scaleup-storage/src/test/java/org/jclouds/scaleup/storage/blobstore/ScaleUpStorageBlobSignerLiveTest.java (100%) rename {providers => sandbox-providers}/scaleup-storage/src/test/java/org/jclouds/scaleup/storage/blobstore/ScaleUpStorageContainerIntegrationLiveTest.java (100%) rename {providers => sandbox-providers}/scaleup-storage/src/test/java/org/jclouds/scaleup/storage/blobstore/ScaleUpStorageContainerLiveTest.java (100%) rename {providers => sandbox-providers}/scaleup-storage/src/test/java/org/jclouds/scaleup/storage/blobstore/ScaleUpStorageInputStreamMapIntegrationLiveTest.java (100%) rename {providers => sandbox-providers}/scaleup-storage/src/test/java/org/jclouds/scaleup/storage/blobstore/ScaleUpStorageServiceIntegrationLiveTest.java (100%) rename {providers => sandbox-providers}/scaleup-storage/src/test/java/org/jclouds/scaleup/storage/blobstore/ScaleUpStorageTestInitializer.java (100%) rename {providers => sandbox-providers}/tiscali-storage/pom.xml (100%) rename {providers => sandbox-providers}/tiscali-storage/src/main/java/org/jclouds/tiscali/storage/TiscaliStoragePropertiesBuilder.java (100%) rename {providers => sandbox-providers}/tiscali-storage/src/test/java/org/jclouds/tiscali/storage/TiscaliStorageClientLiveTest.java (100%) rename {providers => sandbox-providers}/tiscali-storage/src/test/java/org/jclouds/tiscali/storage/blobstore/TiscaliStorageBlobIntegrationLiveTest.java (100%) rename {providers => sandbox-providers}/tiscali-storage/src/test/java/org/jclouds/tiscali/storage/blobstore/TiscaliStorageBlobLiveTest.java (100%) rename {providers => sandbox-providers}/tiscali-storage/src/test/java/org/jclouds/tiscali/storage/blobstore/TiscaliStorageBlobMapIntegrationLiveTest.java (100%) rename {providers => sandbox-providers}/tiscali-storage/src/test/java/org/jclouds/tiscali/storage/blobstore/TiscaliStorageBlobSignerLiveTest.java (100%) rename {providers => sandbox-providers}/tiscali-storage/src/test/java/org/jclouds/tiscali/storage/blobstore/TiscaliStorageContainerIntegrationLiveTest.java (100%) rename {providers => sandbox-providers}/tiscali-storage/src/test/java/org/jclouds/tiscali/storage/blobstore/TiscaliStorageContainerLiveTest.java (100%) rename {providers => sandbox-providers}/tiscali-storage/src/test/java/org/jclouds/tiscali/storage/blobstore/TiscaliStorageInputStreamMapIntegrationLiveTest.java (100%) rename {providers => sandbox-providers}/tiscali-storage/src/test/java/org/jclouds/tiscali/storage/blobstore/TiscaliStorageServiceIntegrationLiveTest.java (100%) rename {providers => sandbox-providers}/tiscali-storage/src/test/java/org/jclouds/tiscali/storage/blobstore/TiscaliStorageTestInitializer.java (100%) diff --git a/README.txt b/README.txt index 44a5a78f0c..211789572a 100644 --- a/README.txt +++ b/README.txt @@ -42,9 +42,8 @@ our compute api supports: aws-ec2, gogrid, cloudservers-us, stub (in-memory), de to all of these providers our blobstore api supports: aws-s3, cloudfiles-us, cloudfiles-uk, filesystem, - azureblob, atmos (generic), synaptic-storage, scaleup-storage, + azureblob, atmos (generic), synaptic-storage, cloudonestorage, walrus(generic), googlestorage, ninefold-storage, - scality-rs2 (generic), hosteurope-storage, tiscali-storage, eucalyptus-partnercloud-s3, swift (generic), transient (in-mem) * note * the pom dependency org.jclouds/jclouds-allblobstore gives you access to @@ -55,7 +54,8 @@ our loadbalancer api supports: cloudloadbalancers-us * note * the pom dependency org.jclouds/jclouds-allloadbalancer gives you access to to all of these providers -we also have support for: ibmdev, mezeo, nirvanix, boxdotnet, openstack nova, +we also have support for: ibmdev, mezeo, nirvanix, boxdotnet, openstack nova, scality ring, + hosteurope-storage, tiscali-storage, scaleup-storage, azurequeue, simpledb, cloudstack as well as a async-http-client driver in the sandbox diff --git a/allblobstore/pom.xml b/allblobstore/pom.xml index a3d04a5691..4b562625d1 100644 --- a/allblobstore/pom.xml +++ b/allblobstore/pom.xml @@ -44,31 +44,11 @@ googlestorage ${project.version} - - org.jclouds.api - scality-rs2 - ${project.version} - org.jclouds.provider ninefold-storage ${project.version} - - org.jclouds.provider - scaleup-storage - ${project.version} - - - org.jclouds.provider - tiscali-storage - ${project.version} - - - org.jclouds.provider - hosteurope-storage - ${project.version} - org.jclouds.provider synaptic-storage diff --git a/apis/pom.xml b/apis/pom.xml index d69cc78bac..42ecc2d880 100644 --- a/apis/pom.xml +++ b/apis/pom.xml @@ -39,7 +39,6 @@ ec2 deltacloud walrus - scality-rs2 eucalyptus swift cloudfiles diff --git a/providers/pom.xml b/providers/pom.xml index 5db5034f4d..09340186e1 100644 --- a/providers/pom.xml +++ b/providers/pom.xml @@ -40,9 +40,6 @@ aws-s3 aws-ec2 googlestorage - scaleup-storage - tiscali-storage - hosteurope-storage synaptic-storage ninefold-storage cloudonestorage diff --git a/apis/scality-rs2/README.txt b/sandbox-apis/scality-rs2/README.txt similarity index 100% rename from apis/scality-rs2/README.txt rename to sandbox-apis/scality-rs2/README.txt diff --git a/apis/scality-rs2/pom.xml b/sandbox-apis/scality-rs2/pom.xml similarity index 100% rename from apis/scality-rs2/pom.xml rename to sandbox-apis/scality-rs2/pom.xml diff --git a/apis/scality-rs2/src/main/java/org/jclouds/scality/rs2/ScalityRS2AsyncClient.java b/sandbox-apis/scality-rs2/src/main/java/org/jclouds/scality/rs2/ScalityRS2AsyncClient.java similarity index 100% rename from apis/scality-rs2/src/main/java/org/jclouds/scality/rs2/ScalityRS2AsyncClient.java rename to sandbox-apis/scality-rs2/src/main/java/org/jclouds/scality/rs2/ScalityRS2AsyncClient.java diff --git a/apis/scality-rs2/src/main/java/org/jclouds/scality/rs2/ScalityRS2ContextBuilder.java b/sandbox-apis/scality-rs2/src/main/java/org/jclouds/scality/rs2/ScalityRS2ContextBuilder.java similarity index 100% rename from apis/scality-rs2/src/main/java/org/jclouds/scality/rs2/ScalityRS2ContextBuilder.java rename to sandbox-apis/scality-rs2/src/main/java/org/jclouds/scality/rs2/ScalityRS2ContextBuilder.java diff --git a/apis/scality-rs2/src/main/java/org/jclouds/scality/rs2/ScalityRS2PropertiesBuilder.java b/sandbox-apis/scality-rs2/src/main/java/org/jclouds/scality/rs2/ScalityRS2PropertiesBuilder.java similarity index 100% rename from apis/scality-rs2/src/main/java/org/jclouds/scality/rs2/ScalityRS2PropertiesBuilder.java rename to sandbox-apis/scality-rs2/src/main/java/org/jclouds/scality/rs2/ScalityRS2PropertiesBuilder.java diff --git a/apis/scality-rs2/src/main/java/org/jclouds/scality/rs2/blobstore/config/ScalityRS2BlobStoreContextModule.java b/sandbox-apis/scality-rs2/src/main/java/org/jclouds/scality/rs2/blobstore/config/ScalityRS2BlobStoreContextModule.java similarity index 100% rename from apis/scality-rs2/src/main/java/org/jclouds/scality/rs2/blobstore/config/ScalityRS2BlobStoreContextModule.java rename to sandbox-apis/scality-rs2/src/main/java/org/jclouds/scality/rs2/blobstore/config/ScalityRS2BlobStoreContextModule.java diff --git a/apis/scality-rs2/src/main/java/org/jclouds/scality/rs2/config/ScalityRS2RestClientModule.java b/sandbox-apis/scality-rs2/src/main/java/org/jclouds/scality/rs2/config/ScalityRS2RestClientModule.java similarity index 100% rename from apis/scality-rs2/src/main/java/org/jclouds/scality/rs2/config/ScalityRS2RestClientModule.java rename to sandbox-apis/scality-rs2/src/main/java/org/jclouds/scality/rs2/config/ScalityRS2RestClientModule.java diff --git a/apis/scality-rs2/src/test/java/org/jclouds/scality/rs2/ScalityRS2AsyncClientTestDisabled.java b/sandbox-apis/scality-rs2/src/test/java/org/jclouds/scality/rs2/ScalityRS2AsyncClientTestDisabled.java similarity index 100% rename from apis/scality-rs2/src/test/java/org/jclouds/scality/rs2/ScalityRS2AsyncClientTestDisabled.java rename to sandbox-apis/scality-rs2/src/test/java/org/jclouds/scality/rs2/ScalityRS2AsyncClientTestDisabled.java diff --git a/apis/scality-rs2/src/test/java/org/jclouds/scality/rs2/ScalityRS2ClientLiveTest.java b/sandbox-apis/scality-rs2/src/test/java/org/jclouds/scality/rs2/ScalityRS2ClientLiveTest.java similarity index 100% rename from apis/scality-rs2/src/test/java/org/jclouds/scality/rs2/ScalityRS2ClientLiveTest.java rename to sandbox-apis/scality-rs2/src/test/java/org/jclouds/scality/rs2/ScalityRS2ClientLiveTest.java diff --git a/apis/scality-rs2/src/test/java/org/jclouds/scality/rs2/blobstore/ScalityRS2BlobIntegrationLiveTest.java b/sandbox-apis/scality-rs2/src/test/java/org/jclouds/scality/rs2/blobstore/ScalityRS2BlobIntegrationLiveTest.java similarity index 100% rename from apis/scality-rs2/src/test/java/org/jclouds/scality/rs2/blobstore/ScalityRS2BlobIntegrationLiveTest.java rename to sandbox-apis/scality-rs2/src/test/java/org/jclouds/scality/rs2/blobstore/ScalityRS2BlobIntegrationLiveTest.java diff --git a/apis/scality-rs2/src/test/java/org/jclouds/scality/rs2/blobstore/ScalityRS2BlobLiveTest.java b/sandbox-apis/scality-rs2/src/test/java/org/jclouds/scality/rs2/blobstore/ScalityRS2BlobLiveTest.java similarity index 100% rename from apis/scality-rs2/src/test/java/org/jclouds/scality/rs2/blobstore/ScalityRS2BlobLiveTest.java rename to sandbox-apis/scality-rs2/src/test/java/org/jclouds/scality/rs2/blobstore/ScalityRS2BlobLiveTest.java diff --git a/apis/scality-rs2/src/test/java/org/jclouds/scality/rs2/blobstore/ScalityRS2BlobMapIntegrationLiveTest.java b/sandbox-apis/scality-rs2/src/test/java/org/jclouds/scality/rs2/blobstore/ScalityRS2BlobMapIntegrationLiveTest.java similarity index 100% rename from apis/scality-rs2/src/test/java/org/jclouds/scality/rs2/blobstore/ScalityRS2BlobMapIntegrationLiveTest.java rename to sandbox-apis/scality-rs2/src/test/java/org/jclouds/scality/rs2/blobstore/ScalityRS2BlobMapIntegrationLiveTest.java diff --git a/apis/scality-rs2/src/test/java/org/jclouds/scality/rs2/blobstore/ScalityRS2BlobSignerLiveTest.java b/sandbox-apis/scality-rs2/src/test/java/org/jclouds/scality/rs2/blobstore/ScalityRS2BlobSignerLiveTest.java similarity index 100% rename from apis/scality-rs2/src/test/java/org/jclouds/scality/rs2/blobstore/ScalityRS2BlobSignerLiveTest.java rename to sandbox-apis/scality-rs2/src/test/java/org/jclouds/scality/rs2/blobstore/ScalityRS2BlobSignerLiveTest.java diff --git a/apis/scality-rs2/src/test/java/org/jclouds/scality/rs2/blobstore/ScalityRS2ContainerIntegrationLiveTest.java b/sandbox-apis/scality-rs2/src/test/java/org/jclouds/scality/rs2/blobstore/ScalityRS2ContainerIntegrationLiveTest.java similarity index 100% rename from apis/scality-rs2/src/test/java/org/jclouds/scality/rs2/blobstore/ScalityRS2ContainerIntegrationLiveTest.java rename to sandbox-apis/scality-rs2/src/test/java/org/jclouds/scality/rs2/blobstore/ScalityRS2ContainerIntegrationLiveTest.java diff --git a/apis/scality-rs2/src/test/java/org/jclouds/scality/rs2/blobstore/ScalityRS2ContainerLiveTest.java b/sandbox-apis/scality-rs2/src/test/java/org/jclouds/scality/rs2/blobstore/ScalityRS2ContainerLiveTest.java similarity index 100% rename from apis/scality-rs2/src/test/java/org/jclouds/scality/rs2/blobstore/ScalityRS2ContainerLiveTest.java rename to sandbox-apis/scality-rs2/src/test/java/org/jclouds/scality/rs2/blobstore/ScalityRS2ContainerLiveTest.java diff --git a/apis/scality-rs2/src/test/java/org/jclouds/scality/rs2/blobstore/ScalityRS2InputStreamMapIntegrationLiveTest.java b/sandbox-apis/scality-rs2/src/test/java/org/jclouds/scality/rs2/blobstore/ScalityRS2InputStreamMapIntegrationLiveTest.java similarity index 100% rename from apis/scality-rs2/src/test/java/org/jclouds/scality/rs2/blobstore/ScalityRS2InputStreamMapIntegrationLiveTest.java rename to sandbox-apis/scality-rs2/src/test/java/org/jclouds/scality/rs2/blobstore/ScalityRS2InputStreamMapIntegrationLiveTest.java diff --git a/apis/scality-rs2/src/test/java/org/jclouds/scality/rs2/blobstore/ScalityRS2ServiceIntegrationLiveTest.java b/sandbox-apis/scality-rs2/src/test/java/org/jclouds/scality/rs2/blobstore/ScalityRS2ServiceIntegrationLiveTest.java similarity index 100% rename from apis/scality-rs2/src/test/java/org/jclouds/scality/rs2/blobstore/ScalityRS2ServiceIntegrationLiveTest.java rename to sandbox-apis/scality-rs2/src/test/java/org/jclouds/scality/rs2/blobstore/ScalityRS2ServiceIntegrationLiveTest.java diff --git a/apis/scality-rs2/src/test/java/org/jclouds/scality/rs2/blobstore/ScalityRS2TestInitializer.java b/sandbox-apis/scality-rs2/src/test/java/org/jclouds/scality/rs2/blobstore/ScalityRS2TestInitializer.java similarity index 100% rename from apis/scality-rs2/src/test/java/org/jclouds/scality/rs2/blobstore/ScalityRS2TestInitializer.java rename to sandbox-apis/scality-rs2/src/test/java/org/jclouds/scality/rs2/blobstore/ScalityRS2TestInitializer.java diff --git a/providers/hosteurope-storage/pom.xml b/sandbox-providers/hosteurope-storage/pom.xml similarity index 100% rename from providers/hosteurope-storage/pom.xml rename to sandbox-providers/hosteurope-storage/pom.xml diff --git a/providers/hosteurope-storage/src/main/java/org/jclouds/hosteurope/storage/HostEuropeStoragePropertiesBuilder.java b/sandbox-providers/hosteurope-storage/src/main/java/org/jclouds/hosteurope/storage/HostEuropeStoragePropertiesBuilder.java similarity index 100% rename from providers/hosteurope-storage/src/main/java/org/jclouds/hosteurope/storage/HostEuropeStoragePropertiesBuilder.java rename to sandbox-providers/hosteurope-storage/src/main/java/org/jclouds/hosteurope/storage/HostEuropeStoragePropertiesBuilder.java diff --git a/providers/hosteurope-storage/src/test/java/org/jclouds/hosteurope/storage/HostEuropeStorageClientLiveTest.java b/sandbox-providers/hosteurope-storage/src/test/java/org/jclouds/hosteurope/storage/HostEuropeStorageClientLiveTest.java similarity index 100% rename from providers/hosteurope-storage/src/test/java/org/jclouds/hosteurope/storage/HostEuropeStorageClientLiveTest.java rename to sandbox-providers/hosteurope-storage/src/test/java/org/jclouds/hosteurope/storage/HostEuropeStorageClientLiveTest.java diff --git a/providers/hosteurope-storage/src/test/java/org/jclouds/hosteurope/storage/blobstore/HostEuropeStorageBlobIntegrationLiveTest.java b/sandbox-providers/hosteurope-storage/src/test/java/org/jclouds/hosteurope/storage/blobstore/HostEuropeStorageBlobIntegrationLiveTest.java similarity index 100% rename from providers/hosteurope-storage/src/test/java/org/jclouds/hosteurope/storage/blobstore/HostEuropeStorageBlobIntegrationLiveTest.java rename to sandbox-providers/hosteurope-storage/src/test/java/org/jclouds/hosteurope/storage/blobstore/HostEuropeStorageBlobIntegrationLiveTest.java diff --git a/providers/hosteurope-storage/src/test/java/org/jclouds/hosteurope/storage/blobstore/HostEuropeStorageBlobLiveTest.java b/sandbox-providers/hosteurope-storage/src/test/java/org/jclouds/hosteurope/storage/blobstore/HostEuropeStorageBlobLiveTest.java similarity index 100% rename from providers/hosteurope-storage/src/test/java/org/jclouds/hosteurope/storage/blobstore/HostEuropeStorageBlobLiveTest.java rename to sandbox-providers/hosteurope-storage/src/test/java/org/jclouds/hosteurope/storage/blobstore/HostEuropeStorageBlobLiveTest.java diff --git a/providers/hosteurope-storage/src/test/java/org/jclouds/hosteurope/storage/blobstore/HostEuropeStorageBlobMapIntegrationLiveTest.java b/sandbox-providers/hosteurope-storage/src/test/java/org/jclouds/hosteurope/storage/blobstore/HostEuropeStorageBlobMapIntegrationLiveTest.java similarity index 100% rename from providers/hosteurope-storage/src/test/java/org/jclouds/hosteurope/storage/blobstore/HostEuropeStorageBlobMapIntegrationLiveTest.java rename to sandbox-providers/hosteurope-storage/src/test/java/org/jclouds/hosteurope/storage/blobstore/HostEuropeStorageBlobMapIntegrationLiveTest.java diff --git a/providers/hosteurope-storage/src/test/java/org/jclouds/hosteurope/storage/blobstore/HostEuropeStorageBlobSignerLiveTest.java b/sandbox-providers/hosteurope-storage/src/test/java/org/jclouds/hosteurope/storage/blobstore/HostEuropeStorageBlobSignerLiveTest.java similarity index 100% rename from providers/hosteurope-storage/src/test/java/org/jclouds/hosteurope/storage/blobstore/HostEuropeStorageBlobSignerLiveTest.java rename to sandbox-providers/hosteurope-storage/src/test/java/org/jclouds/hosteurope/storage/blobstore/HostEuropeStorageBlobSignerLiveTest.java diff --git a/providers/hosteurope-storage/src/test/java/org/jclouds/hosteurope/storage/blobstore/HostEuropeStorageContainerIntegrationLiveTest.java b/sandbox-providers/hosteurope-storage/src/test/java/org/jclouds/hosteurope/storage/blobstore/HostEuropeStorageContainerIntegrationLiveTest.java similarity index 100% rename from providers/hosteurope-storage/src/test/java/org/jclouds/hosteurope/storage/blobstore/HostEuropeStorageContainerIntegrationLiveTest.java rename to sandbox-providers/hosteurope-storage/src/test/java/org/jclouds/hosteurope/storage/blobstore/HostEuropeStorageContainerIntegrationLiveTest.java diff --git a/providers/hosteurope-storage/src/test/java/org/jclouds/hosteurope/storage/blobstore/HostEuropeStorageContainerLiveTest.java b/sandbox-providers/hosteurope-storage/src/test/java/org/jclouds/hosteurope/storage/blobstore/HostEuropeStorageContainerLiveTest.java similarity index 100% rename from providers/hosteurope-storage/src/test/java/org/jclouds/hosteurope/storage/blobstore/HostEuropeStorageContainerLiveTest.java rename to sandbox-providers/hosteurope-storage/src/test/java/org/jclouds/hosteurope/storage/blobstore/HostEuropeStorageContainerLiveTest.java diff --git a/providers/hosteurope-storage/src/test/java/org/jclouds/hosteurope/storage/blobstore/HostEuropeStorageInputStreamMapIntegrationLiveTest.java b/sandbox-providers/hosteurope-storage/src/test/java/org/jclouds/hosteurope/storage/blobstore/HostEuropeStorageInputStreamMapIntegrationLiveTest.java similarity index 100% rename from providers/hosteurope-storage/src/test/java/org/jclouds/hosteurope/storage/blobstore/HostEuropeStorageInputStreamMapIntegrationLiveTest.java rename to sandbox-providers/hosteurope-storage/src/test/java/org/jclouds/hosteurope/storage/blobstore/HostEuropeStorageInputStreamMapIntegrationLiveTest.java diff --git a/providers/hosteurope-storage/src/test/java/org/jclouds/hosteurope/storage/blobstore/HostEuropeStorageServiceIntegrationLiveTest.java b/sandbox-providers/hosteurope-storage/src/test/java/org/jclouds/hosteurope/storage/blobstore/HostEuropeStorageServiceIntegrationLiveTest.java similarity index 100% rename from providers/hosteurope-storage/src/test/java/org/jclouds/hosteurope/storage/blobstore/HostEuropeStorageServiceIntegrationLiveTest.java rename to sandbox-providers/hosteurope-storage/src/test/java/org/jclouds/hosteurope/storage/blobstore/HostEuropeStorageServiceIntegrationLiveTest.java diff --git a/providers/hosteurope-storage/src/test/java/org/jclouds/hosteurope/storage/blobstore/HostEuropeStorageTestInitializer.java b/sandbox-providers/hosteurope-storage/src/test/java/org/jclouds/hosteurope/storage/blobstore/HostEuropeStorageTestInitializer.java similarity index 100% rename from providers/hosteurope-storage/src/test/java/org/jclouds/hosteurope/storage/blobstore/HostEuropeStorageTestInitializer.java rename to sandbox-providers/hosteurope-storage/src/test/java/org/jclouds/hosteurope/storage/blobstore/HostEuropeStorageTestInitializer.java diff --git a/providers/scaleup-storage/README.txt b/sandbox-providers/scaleup-storage/README.txt similarity index 100% rename from providers/scaleup-storage/README.txt rename to sandbox-providers/scaleup-storage/README.txt diff --git a/providers/scaleup-storage/pom.xml b/sandbox-providers/scaleup-storage/pom.xml similarity index 100% rename from providers/scaleup-storage/pom.xml rename to sandbox-providers/scaleup-storage/pom.xml diff --git a/providers/scaleup-storage/src/main/java/org/jclouds/scaleup/storage/ScaleUpStoragePropertiesBuilder.java b/sandbox-providers/scaleup-storage/src/main/java/org/jclouds/scaleup/storage/ScaleUpStoragePropertiesBuilder.java similarity index 100% rename from providers/scaleup-storage/src/main/java/org/jclouds/scaleup/storage/ScaleUpStoragePropertiesBuilder.java rename to sandbox-providers/scaleup-storage/src/main/java/org/jclouds/scaleup/storage/ScaleUpStoragePropertiesBuilder.java diff --git a/providers/scaleup-storage/src/test/java/org/jclouds/scaleup/storage/ScaleUpStorageClientLiveTest.java b/sandbox-providers/scaleup-storage/src/test/java/org/jclouds/scaleup/storage/ScaleUpStorageClientLiveTest.java similarity index 100% rename from providers/scaleup-storage/src/test/java/org/jclouds/scaleup/storage/ScaleUpStorageClientLiveTest.java rename to sandbox-providers/scaleup-storage/src/test/java/org/jclouds/scaleup/storage/ScaleUpStorageClientLiveTest.java diff --git a/providers/scaleup-storage/src/test/java/org/jclouds/scaleup/storage/blobstore/ScaleUpStorageBlobIntegrationLiveTest.java b/sandbox-providers/scaleup-storage/src/test/java/org/jclouds/scaleup/storage/blobstore/ScaleUpStorageBlobIntegrationLiveTest.java similarity index 100% rename from providers/scaleup-storage/src/test/java/org/jclouds/scaleup/storage/blobstore/ScaleUpStorageBlobIntegrationLiveTest.java rename to sandbox-providers/scaleup-storage/src/test/java/org/jclouds/scaleup/storage/blobstore/ScaleUpStorageBlobIntegrationLiveTest.java diff --git a/providers/scaleup-storage/src/test/java/org/jclouds/scaleup/storage/blobstore/ScaleUpStorageBlobLiveTest.java b/sandbox-providers/scaleup-storage/src/test/java/org/jclouds/scaleup/storage/blobstore/ScaleUpStorageBlobLiveTest.java similarity index 100% rename from providers/scaleup-storage/src/test/java/org/jclouds/scaleup/storage/blobstore/ScaleUpStorageBlobLiveTest.java rename to sandbox-providers/scaleup-storage/src/test/java/org/jclouds/scaleup/storage/blobstore/ScaleUpStorageBlobLiveTest.java diff --git a/providers/scaleup-storage/src/test/java/org/jclouds/scaleup/storage/blobstore/ScaleUpStorageBlobMapIntegrationLiveTest.java b/sandbox-providers/scaleup-storage/src/test/java/org/jclouds/scaleup/storage/blobstore/ScaleUpStorageBlobMapIntegrationLiveTest.java similarity index 100% rename from providers/scaleup-storage/src/test/java/org/jclouds/scaleup/storage/blobstore/ScaleUpStorageBlobMapIntegrationLiveTest.java rename to sandbox-providers/scaleup-storage/src/test/java/org/jclouds/scaleup/storage/blobstore/ScaleUpStorageBlobMapIntegrationLiveTest.java diff --git a/providers/scaleup-storage/src/test/java/org/jclouds/scaleup/storage/blobstore/ScaleUpStorageBlobSignerLiveTest.java b/sandbox-providers/scaleup-storage/src/test/java/org/jclouds/scaleup/storage/blobstore/ScaleUpStorageBlobSignerLiveTest.java similarity index 100% rename from providers/scaleup-storage/src/test/java/org/jclouds/scaleup/storage/blobstore/ScaleUpStorageBlobSignerLiveTest.java rename to sandbox-providers/scaleup-storage/src/test/java/org/jclouds/scaleup/storage/blobstore/ScaleUpStorageBlobSignerLiveTest.java diff --git a/providers/scaleup-storage/src/test/java/org/jclouds/scaleup/storage/blobstore/ScaleUpStorageContainerIntegrationLiveTest.java b/sandbox-providers/scaleup-storage/src/test/java/org/jclouds/scaleup/storage/blobstore/ScaleUpStorageContainerIntegrationLiveTest.java similarity index 100% rename from providers/scaleup-storage/src/test/java/org/jclouds/scaleup/storage/blobstore/ScaleUpStorageContainerIntegrationLiveTest.java rename to sandbox-providers/scaleup-storage/src/test/java/org/jclouds/scaleup/storage/blobstore/ScaleUpStorageContainerIntegrationLiveTest.java diff --git a/providers/scaleup-storage/src/test/java/org/jclouds/scaleup/storage/blobstore/ScaleUpStorageContainerLiveTest.java b/sandbox-providers/scaleup-storage/src/test/java/org/jclouds/scaleup/storage/blobstore/ScaleUpStorageContainerLiveTest.java similarity index 100% rename from providers/scaleup-storage/src/test/java/org/jclouds/scaleup/storage/blobstore/ScaleUpStorageContainerLiveTest.java rename to sandbox-providers/scaleup-storage/src/test/java/org/jclouds/scaleup/storage/blobstore/ScaleUpStorageContainerLiveTest.java diff --git a/providers/scaleup-storage/src/test/java/org/jclouds/scaleup/storage/blobstore/ScaleUpStorageInputStreamMapIntegrationLiveTest.java b/sandbox-providers/scaleup-storage/src/test/java/org/jclouds/scaleup/storage/blobstore/ScaleUpStorageInputStreamMapIntegrationLiveTest.java similarity index 100% rename from providers/scaleup-storage/src/test/java/org/jclouds/scaleup/storage/blobstore/ScaleUpStorageInputStreamMapIntegrationLiveTest.java rename to sandbox-providers/scaleup-storage/src/test/java/org/jclouds/scaleup/storage/blobstore/ScaleUpStorageInputStreamMapIntegrationLiveTest.java diff --git a/providers/scaleup-storage/src/test/java/org/jclouds/scaleup/storage/blobstore/ScaleUpStorageServiceIntegrationLiveTest.java b/sandbox-providers/scaleup-storage/src/test/java/org/jclouds/scaleup/storage/blobstore/ScaleUpStorageServiceIntegrationLiveTest.java similarity index 100% rename from providers/scaleup-storage/src/test/java/org/jclouds/scaleup/storage/blobstore/ScaleUpStorageServiceIntegrationLiveTest.java rename to sandbox-providers/scaleup-storage/src/test/java/org/jclouds/scaleup/storage/blobstore/ScaleUpStorageServiceIntegrationLiveTest.java diff --git a/providers/scaleup-storage/src/test/java/org/jclouds/scaleup/storage/blobstore/ScaleUpStorageTestInitializer.java b/sandbox-providers/scaleup-storage/src/test/java/org/jclouds/scaleup/storage/blobstore/ScaleUpStorageTestInitializer.java similarity index 100% rename from providers/scaleup-storage/src/test/java/org/jclouds/scaleup/storage/blobstore/ScaleUpStorageTestInitializer.java rename to sandbox-providers/scaleup-storage/src/test/java/org/jclouds/scaleup/storage/blobstore/ScaleUpStorageTestInitializer.java diff --git a/providers/tiscali-storage/pom.xml b/sandbox-providers/tiscali-storage/pom.xml similarity index 100% rename from providers/tiscali-storage/pom.xml rename to sandbox-providers/tiscali-storage/pom.xml diff --git a/providers/tiscali-storage/src/main/java/org/jclouds/tiscali/storage/TiscaliStoragePropertiesBuilder.java b/sandbox-providers/tiscali-storage/src/main/java/org/jclouds/tiscali/storage/TiscaliStoragePropertiesBuilder.java similarity index 100% rename from providers/tiscali-storage/src/main/java/org/jclouds/tiscali/storage/TiscaliStoragePropertiesBuilder.java rename to sandbox-providers/tiscali-storage/src/main/java/org/jclouds/tiscali/storage/TiscaliStoragePropertiesBuilder.java diff --git a/providers/tiscali-storage/src/test/java/org/jclouds/tiscali/storage/TiscaliStorageClientLiveTest.java b/sandbox-providers/tiscali-storage/src/test/java/org/jclouds/tiscali/storage/TiscaliStorageClientLiveTest.java similarity index 100% rename from providers/tiscali-storage/src/test/java/org/jclouds/tiscali/storage/TiscaliStorageClientLiveTest.java rename to sandbox-providers/tiscali-storage/src/test/java/org/jclouds/tiscali/storage/TiscaliStorageClientLiveTest.java diff --git a/providers/tiscali-storage/src/test/java/org/jclouds/tiscali/storage/blobstore/TiscaliStorageBlobIntegrationLiveTest.java b/sandbox-providers/tiscali-storage/src/test/java/org/jclouds/tiscali/storage/blobstore/TiscaliStorageBlobIntegrationLiveTest.java similarity index 100% rename from providers/tiscali-storage/src/test/java/org/jclouds/tiscali/storage/blobstore/TiscaliStorageBlobIntegrationLiveTest.java rename to sandbox-providers/tiscali-storage/src/test/java/org/jclouds/tiscali/storage/blobstore/TiscaliStorageBlobIntegrationLiveTest.java diff --git a/providers/tiscali-storage/src/test/java/org/jclouds/tiscali/storage/blobstore/TiscaliStorageBlobLiveTest.java b/sandbox-providers/tiscali-storage/src/test/java/org/jclouds/tiscali/storage/blobstore/TiscaliStorageBlobLiveTest.java similarity index 100% rename from providers/tiscali-storage/src/test/java/org/jclouds/tiscali/storage/blobstore/TiscaliStorageBlobLiveTest.java rename to sandbox-providers/tiscali-storage/src/test/java/org/jclouds/tiscali/storage/blobstore/TiscaliStorageBlobLiveTest.java diff --git a/providers/tiscali-storage/src/test/java/org/jclouds/tiscali/storage/blobstore/TiscaliStorageBlobMapIntegrationLiveTest.java b/sandbox-providers/tiscali-storage/src/test/java/org/jclouds/tiscali/storage/blobstore/TiscaliStorageBlobMapIntegrationLiveTest.java similarity index 100% rename from providers/tiscali-storage/src/test/java/org/jclouds/tiscali/storage/blobstore/TiscaliStorageBlobMapIntegrationLiveTest.java rename to sandbox-providers/tiscali-storage/src/test/java/org/jclouds/tiscali/storage/blobstore/TiscaliStorageBlobMapIntegrationLiveTest.java diff --git a/providers/tiscali-storage/src/test/java/org/jclouds/tiscali/storage/blobstore/TiscaliStorageBlobSignerLiveTest.java b/sandbox-providers/tiscali-storage/src/test/java/org/jclouds/tiscali/storage/blobstore/TiscaliStorageBlobSignerLiveTest.java similarity index 100% rename from providers/tiscali-storage/src/test/java/org/jclouds/tiscali/storage/blobstore/TiscaliStorageBlobSignerLiveTest.java rename to sandbox-providers/tiscali-storage/src/test/java/org/jclouds/tiscali/storage/blobstore/TiscaliStorageBlobSignerLiveTest.java diff --git a/providers/tiscali-storage/src/test/java/org/jclouds/tiscali/storage/blobstore/TiscaliStorageContainerIntegrationLiveTest.java b/sandbox-providers/tiscali-storage/src/test/java/org/jclouds/tiscali/storage/blobstore/TiscaliStorageContainerIntegrationLiveTest.java similarity index 100% rename from providers/tiscali-storage/src/test/java/org/jclouds/tiscali/storage/blobstore/TiscaliStorageContainerIntegrationLiveTest.java rename to sandbox-providers/tiscali-storage/src/test/java/org/jclouds/tiscali/storage/blobstore/TiscaliStorageContainerIntegrationLiveTest.java diff --git a/providers/tiscali-storage/src/test/java/org/jclouds/tiscali/storage/blobstore/TiscaliStorageContainerLiveTest.java b/sandbox-providers/tiscali-storage/src/test/java/org/jclouds/tiscali/storage/blobstore/TiscaliStorageContainerLiveTest.java similarity index 100% rename from providers/tiscali-storage/src/test/java/org/jclouds/tiscali/storage/blobstore/TiscaliStorageContainerLiveTest.java rename to sandbox-providers/tiscali-storage/src/test/java/org/jclouds/tiscali/storage/blobstore/TiscaliStorageContainerLiveTest.java diff --git a/providers/tiscali-storage/src/test/java/org/jclouds/tiscali/storage/blobstore/TiscaliStorageInputStreamMapIntegrationLiveTest.java b/sandbox-providers/tiscali-storage/src/test/java/org/jclouds/tiscali/storage/blobstore/TiscaliStorageInputStreamMapIntegrationLiveTest.java similarity index 100% rename from providers/tiscali-storage/src/test/java/org/jclouds/tiscali/storage/blobstore/TiscaliStorageInputStreamMapIntegrationLiveTest.java rename to sandbox-providers/tiscali-storage/src/test/java/org/jclouds/tiscali/storage/blobstore/TiscaliStorageInputStreamMapIntegrationLiveTest.java diff --git a/providers/tiscali-storage/src/test/java/org/jclouds/tiscali/storage/blobstore/TiscaliStorageServiceIntegrationLiveTest.java b/sandbox-providers/tiscali-storage/src/test/java/org/jclouds/tiscali/storage/blobstore/TiscaliStorageServiceIntegrationLiveTest.java similarity index 100% rename from providers/tiscali-storage/src/test/java/org/jclouds/tiscali/storage/blobstore/TiscaliStorageServiceIntegrationLiveTest.java rename to sandbox-providers/tiscali-storage/src/test/java/org/jclouds/tiscali/storage/blobstore/TiscaliStorageServiceIntegrationLiveTest.java diff --git a/providers/tiscali-storage/src/test/java/org/jclouds/tiscali/storage/blobstore/TiscaliStorageTestInitializer.java b/sandbox-providers/tiscali-storage/src/test/java/org/jclouds/tiscali/storage/blobstore/TiscaliStorageTestInitializer.java similarity index 100% rename from providers/tiscali-storage/src/test/java/org/jclouds/tiscali/storage/blobstore/TiscaliStorageTestInitializer.java rename to sandbox-providers/tiscali-storage/src/test/java/org/jclouds/tiscali/storage/blobstore/TiscaliStorageTestInitializer.java From 00c55bcdfad1f9ad93de0383e6a072cb1ac056dd Mon Sep 17 00:00:00 2001 From: Gustavo Morozowski Date: Thu, 2 Jun 2011 21:33:48 -0300 Subject: [PATCH 035/264] Issue 550: Added ProviderMetadata for Elastic Hosts. --- .gitignore | 1 + ...HostsBlueSquareLondonProviderMetadata.java | 115 ++++++++++++++++++ .../org.jclouds.providers.ProviderMetadata | 1 + ...sticHostsBlueSquareLondonProviderTest.java | 35 ++++++ ...cHostsPeer1SanAntonioProviderMetadata.java | 115 ++++++++++++++++++ .../org.jclouds.providers.ProviderMetadata | 1 + ...asticHostsPeer1SanAntonioProviderTest.java | 35 ++++++ 7 files changed, 303 insertions(+) create mode 100644 providers/elastichosts-lon-b/src/main/java/org/jclouds/elastichosts/ElasticHostsBlueSquareLondonProviderMetadata.java create mode 100644 providers/elastichosts-lon-b/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata create mode 100644 providers/elastichosts-lon-b/src/test/java/org/jclouds/elastichosts/ElasticHostsBlueSquareLondonProviderTest.java create mode 100644 providers/elastichosts-sat-p/src/main/java/org/jclouds/elastichosts/ElasticHostsPeer1SanAntonioProviderMetadata.java create mode 100644 providers/elastichosts-sat-p/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata create mode 100644 providers/elastichosts-sat-p/src/test/java/org/jclouds/elastichosts/ElasticHostsPeer1SanAntonioProviderTest.java diff --git a/.gitignore b/.gitignore index 6da66153e1..006f24f892 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ syntax: glob target/ test-output/ +bin/ .settings/ .classpath .project diff --git a/providers/elastichosts-lon-b/src/main/java/org/jclouds/elastichosts/ElasticHostsBlueSquareLondonProviderMetadata.java b/providers/elastichosts-lon-b/src/main/java/org/jclouds/elastichosts/ElasticHostsBlueSquareLondonProviderMetadata.java new file mode 100644 index 0000000000..8679430875 --- /dev/null +++ b/providers/elastichosts-lon-b/src/main/java/org/jclouds/elastichosts/ElasticHostsBlueSquareLondonProviderMetadata.java @@ -0,0 +1,115 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.jclouds.elastichosts; + +import com.google.common.collect.ImmutableSet; + +import java.net.URI; +import java.util.Set; + +import org.jclouds.providers.BaseProviderMetadata; +import org.jclouds.providers.ProviderMetadata; + +/** + * Implementation of {@link org.jclouds.types.ProviderMetadata} for ElasticHosts London BlueSquare. + * + * @author Adrian Cole + */ +public class ElasticHostsBlueSquareLondonProviderMetadata extends BaseProviderMetadata { + + /** + * {@inheritDoc} + */ + @Override + public String getId() { + return "elastichosts-lon-b"; + } + + /** + * {@inheritDoc} + */ + @Override + public String getType() { + return ProviderMetadata.COMPUTE_TYPE; + } + + /** + * {@inheritDoc} + */ + @Override + public String getName() { + return "ElasticHosts London BlueSquare"; + } + + /** + * {@inheritDoc} + */ + @Override + public String getIdentityName() { + return "UUID"; + } + + /** + * {@inheritDoc} + */ + @Override + public String getCredentialName() { + return "Secret API key"; + } + + /** + * {@inheritDoc} + */ + @Override + public URI getHomepage() { + return URI.create("https://lon-b.elastichosts.com"); + } + + /** + * {@inheritDoc} + */ + @Override + public URI getConsole() { + return URI.create("https://lon-b.elastichosts.com/accounts"); + } + /** + * {@inheritDoc} + */ + @Override + public URI getApiDocumentation() { + return URI.create("http://www.elastichosts.com/cloud-hosting/api"); + } + + /** + * {@inheritDoc} + */ + @Override + public Set getLinkedServices() { + return ImmutableSet.of("elastichosts-lon-b"); + } + + /** + * {@inheritDoc} + */ + @Override + public Set getIso3166Codes() { + return ImmutableSet.of("GB-LND"); + } + +} \ No newline at end of file diff --git a/providers/elastichosts-lon-b/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata b/providers/elastichosts-lon-b/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata new file mode 100644 index 0000000000..b7305b8ff6 --- /dev/null +++ b/providers/elastichosts-lon-b/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata @@ -0,0 +1 @@ +org.jclouds.elastichosts.ElasticHostsBlueSquareLondonProviderMetadata diff --git a/providers/elastichosts-lon-b/src/test/java/org/jclouds/elastichosts/ElasticHostsBlueSquareLondonProviderTest.java b/providers/elastichosts-lon-b/src/test/java/org/jclouds/elastichosts/ElasticHostsBlueSquareLondonProviderTest.java new file mode 100644 index 0000000000..479b9bbf0a --- /dev/null +++ b/providers/elastichosts-lon-b/src/test/java/org/jclouds/elastichosts/ElasticHostsBlueSquareLondonProviderTest.java @@ -0,0 +1,35 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.jclouds.elastichosts; + +import org.jclouds.providers.BaseProviderMetadataTest; +import org.jclouds.providers.ProviderMetadata; +import org.testng.annotations.Test; + +/** + * + * @author Adrian Cole + */ +@Test(groups = "unit", testName = "ElasticHostsBlueSquareLondonProviderTest") +public class ElasticHostsBlueSquareLondonProviderTest extends BaseProviderMetadataTest { + + public ElasticHostsBlueSquareLondonProviderTest() { + super(new ElasticHostsBlueSquareLondonProviderMetadata(), ProviderMetadata.COMPUTE_TYPE); + } +} \ No newline at end of file diff --git a/providers/elastichosts-sat-p/src/main/java/org/jclouds/elastichosts/ElasticHostsPeer1SanAntonioProviderMetadata.java b/providers/elastichosts-sat-p/src/main/java/org/jclouds/elastichosts/ElasticHostsPeer1SanAntonioProviderMetadata.java new file mode 100644 index 0000000000..fab703473e --- /dev/null +++ b/providers/elastichosts-sat-p/src/main/java/org/jclouds/elastichosts/ElasticHostsPeer1SanAntonioProviderMetadata.java @@ -0,0 +1,115 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.jclouds.elastichosts; + +import com.google.common.collect.ImmutableSet; + +import java.net.URI; +import java.util.Set; + +import org.jclouds.providers.BaseProviderMetadata; +import org.jclouds.providers.ProviderMetadata; + +/** + * Implementation of {@link org.jclouds.types.ProviderMetadata} for ElasticHosts San Antonio Peer 1. + * + * @author Adrian Cole + */ +public class ElasticHostsPeer1SanAntonioProviderMetadata extends BaseProviderMetadata { + + /** + * {@inheritDoc} + */ + @Override + public String getId() { + return "elastichosts-sat-p"; + } + + /** + * {@inheritDoc} + */ + @Override + public String getType() { + return ProviderMetadata.COMPUTE_TYPE; + } + + /** + * {@inheritDoc} + */ + @Override + public String getName() { + return "ElasticHosts San Antonio Peer 1"; + } + + /** + * {@inheritDoc} + */ + @Override + public String getIdentityName() { + return "UUID"; + } + + /** + * {@inheritDoc} + */ + @Override + public String getCredentialName() { + return "Secret API key"; + } + + /** + * {@inheritDoc} + */ + @Override + public URI getHomepage() { + return URI.create("https://sat-p.elastichosts.com"); + } + + /** + * {@inheritDoc} + */ + @Override + public URI getConsole() { + return URI.create("https://sat-p.elastichosts.com/accounts"); + } + /** + * {@inheritDoc} + */ + @Override + public URI getApiDocumentation() { + return URI.create("http://www.elastichosts.com/cloud-hosting/api"); + } + + /** + * {@inheritDoc} + */ + @Override + public Set getLinkedServices() { + return ImmutableSet.of("elastichosts-sat-p"); + } + + /** + * {@inheritDoc} + */ + @Override + public Set getIso3166Codes() { + return ImmutableSet.of("US-TX"); + } + +} \ No newline at end of file diff --git a/providers/elastichosts-sat-p/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata b/providers/elastichosts-sat-p/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata new file mode 100644 index 0000000000..7981420bd9 --- /dev/null +++ b/providers/elastichosts-sat-p/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata @@ -0,0 +1 @@ +org.jclouds.elastichosts.ElasticHostsPeer1SanAntonioProviderMetadata diff --git a/providers/elastichosts-sat-p/src/test/java/org/jclouds/elastichosts/ElasticHostsPeer1SanAntonioProviderTest.java b/providers/elastichosts-sat-p/src/test/java/org/jclouds/elastichosts/ElasticHostsPeer1SanAntonioProviderTest.java new file mode 100644 index 0000000000..8c531b88ca --- /dev/null +++ b/providers/elastichosts-sat-p/src/test/java/org/jclouds/elastichosts/ElasticHostsPeer1SanAntonioProviderTest.java @@ -0,0 +1,35 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.jclouds.elastichosts; + +import org.jclouds.providers.BaseProviderMetadataTest; +import org.jclouds.providers.ProviderMetadata; +import org.testng.annotations.Test; + +/** + * + * @author Adrian Cole + */ +@Test(groups = "unit", testName = "ElasticHostsPeer1SanAntonioProviderTest") +public class ElasticHostsPeer1SanAntonioProviderTest extends BaseProviderMetadataTest { + + public ElasticHostsPeer1SanAntonioProviderTest() { + super(new ElasticHostsPeer1SanAntonioProviderMetadata(), ProviderMetadata.COMPUTE_TYPE); + } +} \ No newline at end of file From c1b7ffb6246036c4824924325511c916b49ff7fc Mon Sep 17 00:00:00 2001 From: Gustavo Morozowski Date: Thu, 2 Jun 2011 22:06:26 -0300 Subject: [PATCH 036/264] Issue 550: Small fixes to Elastic Hosts. --- .../ElasticHostsBlueSquareLondonProviderMetadata.java | 4 ++-- .../ElasticHostsBlueSquareLondonProviderTest.java | 2 +- .../elastichosts/ElasticHostsPeer1LondonProviderMetadata.java | 4 ++-- .../elastichosts/ElasticHostsPeer1LondonProviderTest.java | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/providers/elastichosts-lon-b/src/main/java/org/jclouds/elastichosts/ElasticHostsBlueSquareLondonProviderMetadata.java b/providers/elastichosts-lon-b/src/main/java/org/jclouds/elastichosts/ElasticHostsBlueSquareLondonProviderMetadata.java index 8679430875..f267c3ed6a 100644 --- a/providers/elastichosts-lon-b/src/main/java/org/jclouds/elastichosts/ElasticHostsBlueSquareLondonProviderMetadata.java +++ b/providers/elastichosts-lon-b/src/main/java/org/jclouds/elastichosts/ElasticHostsBlueSquareLondonProviderMetadata.java @@ -70,7 +70,7 @@ public class ElasticHostsBlueSquareLondonProviderMetadata extends BaseProviderMe */ @Override public String getCredentialName() { - return "Secret API key"; + return "Secret API Key"; } /** @@ -112,4 +112,4 @@ public class ElasticHostsBlueSquareLondonProviderMetadata extends BaseProviderMe return ImmutableSet.of("GB-LND"); } -} \ No newline at end of file +} diff --git a/providers/elastichosts-lon-b/src/test/java/org/jclouds/elastichosts/ElasticHostsBlueSquareLondonProviderTest.java b/providers/elastichosts-lon-b/src/test/java/org/jclouds/elastichosts/ElasticHostsBlueSquareLondonProviderTest.java index 479b9bbf0a..e8d1d22809 100644 --- a/providers/elastichosts-lon-b/src/test/java/org/jclouds/elastichosts/ElasticHostsBlueSquareLondonProviderTest.java +++ b/providers/elastichosts-lon-b/src/test/java/org/jclouds/elastichosts/ElasticHostsBlueSquareLondonProviderTest.java @@ -32,4 +32,4 @@ public class ElasticHostsBlueSquareLondonProviderTest extends BaseProviderMetada public ElasticHostsBlueSquareLondonProviderTest() { super(new ElasticHostsBlueSquareLondonProviderMetadata(), ProviderMetadata.COMPUTE_TYPE); } -} \ No newline at end of file +} diff --git a/providers/elastichosts-lon-p/src/main/java/org/jclouds/elastichosts/ElasticHostsPeer1LondonProviderMetadata.java b/providers/elastichosts-lon-p/src/main/java/org/jclouds/elastichosts/ElasticHostsPeer1LondonProviderMetadata.java index ea5259c8ac..2eac34e8d6 100644 --- a/providers/elastichosts-lon-p/src/main/java/org/jclouds/elastichosts/ElasticHostsPeer1LondonProviderMetadata.java +++ b/providers/elastichosts-lon-p/src/main/java/org/jclouds/elastichosts/ElasticHostsPeer1LondonProviderMetadata.java @@ -70,7 +70,7 @@ public class ElasticHostsPeer1LondonProviderMetadata extends BaseProviderMetadat */ @Override public String getCredentialName() { - return "Secret API key"; + return "Secret API Key"; } /** @@ -112,4 +112,4 @@ public class ElasticHostsPeer1LondonProviderMetadata extends BaseProviderMetadat return ImmutableSet.of("GB-LND"); } -} \ No newline at end of file +} diff --git a/providers/elastichosts-lon-p/src/test/java/org/jclouds/elastichosts/ElasticHostsPeer1LondonProviderTest.java b/providers/elastichosts-lon-p/src/test/java/org/jclouds/elastichosts/ElasticHostsPeer1LondonProviderTest.java index fc3286b069..66e3626882 100644 --- a/providers/elastichosts-lon-p/src/test/java/org/jclouds/elastichosts/ElasticHostsPeer1LondonProviderTest.java +++ b/providers/elastichosts-lon-p/src/test/java/org/jclouds/elastichosts/ElasticHostsPeer1LondonProviderTest.java @@ -32,4 +32,4 @@ public class ElasticHostsPeer1LondonProviderTest extends BaseProviderMetadataTes public ElasticHostsPeer1LondonProviderTest() { super(new ElasticHostsPeer1LondonProviderMetadata(), ProviderMetadata.COMPUTE_TYPE); } -} \ No newline at end of file +} From 5ef37784684eb2aa1db778deca61efdd4cc43b81 Mon Sep 17 00:00:00 2001 From: Andrew Phillips Date: Fri, 3 Jun 2011 03:02:12 +0200 Subject: [PATCH 037/264] Converted the TweetStore *app* (not just the tests ;-)) to use OAuth for Twitter --- .../config/SpringServletConfig.java | 15 +++++--- .../reference/TwitterConstants.java | 31 ++++++++++++++++ .../integration/TweetStoreLiveTest.java | 35 +++++++++---------- .../tweetstore/config/GuiceServletConfig.java | 17 ++++++--- .../reference/TwitterConstants.java | 31 ++++++++++++++++ .../integration/TweetStoreLiveTest.java | 35 +++++++++---------- .../tweetstore/config/GuiceServletConfig.java | 14 +++++--- .../reference/TwitterConstants.java | 31 ++++++++++++++++ .../integration/TweetStoreLiveTest.java | 35 +++++++++---------- 9 files changed, 174 insertions(+), 70 deletions(-) create mode 100644 demos/tweetstore/gae-tweetstore-spring/src/main/java/org/jclouds/demo/tweetstore/reference/TwitterConstants.java create mode 100644 demos/tweetstore/gae-tweetstore/src/main/java/org/jclouds/demo/tweetstore/reference/TwitterConstants.java create mode 100644 demos/tweetstore/runatcloud-tweetstore/src/main/java/org/jclouds/demo/tweetstore/reference/TwitterConstants.java diff --git a/demos/tweetstore/gae-tweetstore-spring/src/main/java/org/jclouds/demo/tweetstore/config/SpringServletConfig.java b/demos/tweetstore/gae-tweetstore-spring/src/main/java/org/jclouds/demo/tweetstore/config/SpringServletConfig.java index 5b458d32e0..b836b4cfd6 100644 --- a/demos/tweetstore/gae-tweetstore-spring/src/main/java/org/jclouds/demo/tweetstore/config/SpringServletConfig.java +++ b/demos/tweetstore/gae-tweetstore-spring/src/main/java/org/jclouds/demo/tweetstore/config/SpringServletConfig.java @@ -21,6 +21,10 @@ package org.jclouds.demo.tweetstore.config; import static com.google.appengine.api.taskqueue.TaskOptions.Builder.withUrl; import static com.google.common.base.Preconditions.checkNotNull; import static org.jclouds.demo.tweetstore.reference.TweetStoreConstants.PROPERTY_TWEETSTORE_CONTAINER; +import static org.jclouds.demo.tweetstore.reference.TwitterConstants.PROPERTY_TWITTER_ACCESSTOKEN; +import static org.jclouds.demo.tweetstore.reference.TwitterConstants.PROPERTY_TWITTER_ACCESSTOKEN_SECRET; +import static org.jclouds.demo.tweetstore.reference.TwitterConstants.PROPERTY_TWITTER_CONSUMER_KEY; +import static org.jclouds.demo.tweetstore.reference.TwitterConstants.PROPERTY_TWITTER_CONSUMER_SECRET; import java.io.IOException; import java.io.InputStream; @@ -90,11 +94,14 @@ public class SpringServletConfig extends LoggingConfig implements ServletConfigA // shared across all blobstores and used to retrieve tweets try { twitter4j.conf.Configuration twitterConf = new ConfigurationBuilder() - .setUser(props.getProperty("twitter.identity")) - .setPassword(props.getProperty("twitter.credential")).build(); - twitterClient = new TwitterFactory(twitterConf).getInstance(); + .setOAuthConsumerKey(props.getProperty(PROPERTY_TWITTER_CONSUMER_KEY)) + .setOAuthConsumerSecret(props.getProperty(PROPERTY_TWITTER_CONSUMER_SECRET)) + .setOAuthAccessToken(props.getProperty(PROPERTY_TWITTER_ACCESSTOKEN)) + .setOAuthAccessTokenSecret(props.getProperty(PROPERTY_TWITTER_ACCESSTOKEN_SECRET)) + .build(); + twitterClient = new TwitterFactory(twitterConf).getInstance(); } catch (IllegalArgumentException e) { - throw new IllegalArgumentException("properties for twitter not configured properly in " + props.toString(), e); + throw new IllegalArgumentException("properties for twitter not configured properly in " + props.toString(), e); } // common namespace for storing tweets container = checkNotNull(props.getProperty(PROPERTY_TWEETSTORE_CONTAINER), PROPERTY_TWEETSTORE_CONTAINER); diff --git a/demos/tweetstore/gae-tweetstore-spring/src/main/java/org/jclouds/demo/tweetstore/reference/TwitterConstants.java b/demos/tweetstore/gae-tweetstore-spring/src/main/java/org/jclouds/demo/tweetstore/reference/TwitterConstants.java new file mode 100644 index 0000000000..0075a27976 --- /dev/null +++ b/demos/tweetstore/gae-tweetstore-spring/src/main/java/org/jclouds/demo/tweetstore/reference/TwitterConstants.java @@ -0,0 +1,31 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.jclouds.demo.tweetstore.reference; + +/** + * Configuration properties and constants used in Twitter connections. + * + * @author Andrew Phillips + */ +public interface TwitterConstants { + static final String PROPERTY_TWITTER_CONSUMER_KEY = "twitter.consumer.identity"; + static final String PROPERTY_TWITTER_CONSUMER_SECRET = "twitter.consumer.credential"; + static final String PROPERTY_TWITTER_ACCESSTOKEN = "twitter.access.identity"; + static final String PROPERTY_TWITTER_ACCESSTOKEN_SECRET = "twitter.access.credential"; +} diff --git a/demos/tweetstore/gae-tweetstore-spring/src/test/java/org/jclouds/demo/tweetstore/integration/TweetStoreLiveTest.java b/demos/tweetstore/gae-tweetstore-spring/src/test/java/org/jclouds/demo/tweetstore/integration/TweetStoreLiveTest.java index 3565071db8..be8f4de60e 100644 --- a/demos/tweetstore/gae-tweetstore-spring/src/test/java/org/jclouds/demo/tweetstore/integration/TweetStoreLiveTest.java +++ b/demos/tweetstore/gae-tweetstore-spring/src/test/java/org/jclouds/demo/tweetstore/integration/TweetStoreLiveTest.java @@ -21,6 +21,10 @@ package org.jclouds.demo.tweetstore.integration; import static com.google.common.base.Preconditions.checkNotNull; import static org.jclouds.demo.tweetstore.reference.TweetStoreConstants.PROPERTY_TWEETSTORE_BLOBSTORES; import static org.jclouds.demo.tweetstore.reference.TweetStoreConstants.PROPERTY_TWEETSTORE_CONTAINER; +import static org.jclouds.demo.tweetstore.reference.TwitterConstants.PROPERTY_TWITTER_ACCESSTOKEN; +import static org.jclouds.demo.tweetstore.reference.TwitterConstants.PROPERTY_TWITTER_ACCESSTOKEN_SECRET; +import static org.jclouds.demo.tweetstore.reference.TwitterConstants.PROPERTY_TWITTER_CONSUMER_KEY; +import static org.jclouds.demo.tweetstore.reference.TwitterConstants.PROPERTY_TWITTER_CONSUMER_SECRET; import java.io.IOException; import java.io.InputStream; @@ -100,10 +104,10 @@ public class TweetStoreLiveTest { } Configuration conf = new ConfigurationBuilder() - .setOAuthConsumerKey(props.getProperty(TwitterConstants.PROPERTY_TWITTER_CONSUMER_KEY)) - .setOAuthConsumerSecret(props.getProperty(TwitterConstants.PROPERTY_TWITTER_CONSUMER_SECRET)) - .setOAuthAccessToken(props.getProperty(TwitterConstants.PROPERTY_TWITTER_ACCESSTOKEN)) - .setOAuthAccessTokenSecret(props.getProperty(TwitterConstants.PROPERTY_TWITTER_ACCESSTOKEN_SECRET)) + .setOAuthConsumerKey(props.getProperty(PROPERTY_TWITTER_CONSUMER_KEY)) + .setOAuthConsumerSecret(props.getProperty(PROPERTY_TWITTER_CONSUMER_SECRET)) + .setOAuthAccessToken(props.getProperty(PROPERTY_TWITTER_ACCESSTOKEN)) + .setOAuthAccessTokenSecret(props.getProperty(PROPERTY_TWITTER_ACCESSTOKEN_SECRET)) .build(); Twitter client = new TwitterFactory(conf).getInstance(); StoreTweetsController controller = new StoreTweetsController(contexts, container, client); @@ -144,14 +148,14 @@ public class TweetStoreLiveTest { } private void addConfigurationForTwitter(Properties props) { - props.setProperty(TwitterConstants.PROPERTY_TWITTER_CONSUMER_KEY, - getRequiredSystemProperty("test." + TwitterConstants.PROPERTY_TWITTER_CONSUMER_KEY)); - props.setProperty(TwitterConstants.PROPERTY_TWITTER_CONSUMER_SECRET, - getRequiredSystemProperty("test." + TwitterConstants.PROPERTY_TWITTER_CONSUMER_SECRET)); - props.setProperty(TwitterConstants.PROPERTY_TWITTER_ACCESSTOKEN, - getRequiredSystemProperty("test." + TwitterConstants.PROPERTY_TWITTER_ACCESSTOKEN)); - props.setProperty(TwitterConstants.PROPERTY_TWITTER_ACCESSTOKEN_SECRET, - getRequiredSystemProperty("test." + TwitterConstants.PROPERTY_TWITTER_ACCESSTOKEN_SECRET)); + props.setProperty(PROPERTY_TWITTER_CONSUMER_KEY, + getRequiredSystemProperty("test." + PROPERTY_TWITTER_CONSUMER_KEY)); + props.setProperty(PROPERTY_TWITTER_CONSUMER_SECRET, + getRequiredSystemProperty("test." + PROPERTY_TWITTER_CONSUMER_SECRET)); + props.setProperty(PROPERTY_TWITTER_ACCESSTOKEN, + getRequiredSystemProperty("test." + PROPERTY_TWITTER_ACCESSTOKEN)); + props.setProperty(PROPERTY_TWITTER_ACCESSTOKEN_SECRET, + getRequiredSystemProperty("test." + PROPERTY_TWITTER_ACCESSTOKEN_SECRET)); } private void addCredentialsForBlobStores(Properties props) { @@ -220,11 +224,4 @@ public class TweetStoreLiveTest { String string = Strings2.toStringAndClose(i); assert string.indexOf("Tweets in Clouds") >= 0 : string; } - - private static interface TwitterConstants { - static final String PROPERTY_TWITTER_CONSUMER_KEY = "twitter.consumer.identity"; - static final String PROPERTY_TWITTER_CONSUMER_SECRET = "twitter.consumer.credential"; - static final String PROPERTY_TWITTER_ACCESSTOKEN = "twitter.access.identity"; - static final String PROPERTY_TWITTER_ACCESSTOKEN_SECRET = "twitter.access.credential"; - } } diff --git a/demos/tweetstore/gae-tweetstore/src/main/java/org/jclouds/demo/tweetstore/config/GuiceServletConfig.java b/demos/tweetstore/gae-tweetstore/src/main/java/org/jclouds/demo/tweetstore/config/GuiceServletConfig.java index 6dae4161ea..97240fd280 100644 --- a/demos/tweetstore/gae-tweetstore/src/main/java/org/jclouds/demo/tweetstore/config/GuiceServletConfig.java +++ b/demos/tweetstore/gae-tweetstore/src/main/java/org/jclouds/demo/tweetstore/config/GuiceServletConfig.java @@ -21,6 +21,10 @@ package org.jclouds.demo.tweetstore.config; import static com.google.appengine.api.taskqueue.TaskOptions.Builder.withUrl; import static com.google.common.base.Preconditions.checkNotNull; import static org.jclouds.demo.tweetstore.reference.TweetStoreConstants.PROPERTY_TWEETSTORE_CONTAINER; +import static org.jclouds.demo.tweetstore.reference.TwitterConstants.PROPERTY_TWITTER_ACCESSTOKEN; +import static org.jclouds.demo.tweetstore.reference.TwitterConstants.PROPERTY_TWITTER_ACCESSTOKEN_SECRET; +import static org.jclouds.demo.tweetstore.reference.TwitterConstants.PROPERTY_TWITTER_CONSUMER_KEY; +import static org.jclouds.demo.tweetstore.reference.TwitterConstants.PROPERTY_TWITTER_CONSUMER_SECRET; import java.io.IOException; import java.io.InputStream; @@ -79,12 +83,15 @@ public class GuiceServletConfig extends GuiceServletContextListener { Set modules = ImmutableSet. of(googleModule); // shared across all blobstores and used to retrieve tweets try { - Configuration twitterConf = new ConfigurationBuilder() - .setUser(props.getProperty("twitter.identity")) - .setPassword(props.getProperty("twitter.credential")).build(); - twitterClient = new TwitterFactory(twitterConf).getInstance(); + Configuration twitterConf = new ConfigurationBuilder() + .setOAuthConsumerKey(props.getProperty(PROPERTY_TWITTER_CONSUMER_KEY)) + .setOAuthConsumerSecret(props.getProperty(PROPERTY_TWITTER_CONSUMER_SECRET)) + .setOAuthAccessToken(props.getProperty(PROPERTY_TWITTER_ACCESSTOKEN)) + .setOAuthAccessTokenSecret(props.getProperty(PROPERTY_TWITTER_ACCESSTOKEN_SECRET)) + .build(); + twitterClient = new TwitterFactory(twitterConf).getInstance(); } catch (IllegalArgumentException e) { - throw new IllegalArgumentException("properties for twitter not configured properly in " + props.toString(), e); + throw new IllegalArgumentException("properties for twitter not configured properly in " + props.toString(), e); } // common namespace for storing tweets container = checkNotNull(props.getProperty(PROPERTY_TWEETSTORE_CONTAINER), PROPERTY_TWEETSTORE_CONTAINER); diff --git a/demos/tweetstore/gae-tweetstore/src/main/java/org/jclouds/demo/tweetstore/reference/TwitterConstants.java b/demos/tweetstore/gae-tweetstore/src/main/java/org/jclouds/demo/tweetstore/reference/TwitterConstants.java new file mode 100644 index 0000000000..0075a27976 --- /dev/null +++ b/demos/tweetstore/gae-tweetstore/src/main/java/org/jclouds/demo/tweetstore/reference/TwitterConstants.java @@ -0,0 +1,31 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.jclouds.demo.tweetstore.reference; + +/** + * Configuration properties and constants used in Twitter connections. + * + * @author Andrew Phillips + */ +public interface TwitterConstants { + static final String PROPERTY_TWITTER_CONSUMER_KEY = "twitter.consumer.identity"; + static final String PROPERTY_TWITTER_CONSUMER_SECRET = "twitter.consumer.credential"; + static final String PROPERTY_TWITTER_ACCESSTOKEN = "twitter.access.identity"; + static final String PROPERTY_TWITTER_ACCESSTOKEN_SECRET = "twitter.access.credential"; +} diff --git a/demos/tweetstore/gae-tweetstore/src/test/java/org/jclouds/demo/tweetstore/integration/TweetStoreLiveTest.java b/demos/tweetstore/gae-tweetstore/src/test/java/org/jclouds/demo/tweetstore/integration/TweetStoreLiveTest.java index a2d982a7ae..1ab9aa3a0b 100644 --- a/demos/tweetstore/gae-tweetstore/src/test/java/org/jclouds/demo/tweetstore/integration/TweetStoreLiveTest.java +++ b/demos/tweetstore/gae-tweetstore/src/test/java/org/jclouds/demo/tweetstore/integration/TweetStoreLiveTest.java @@ -21,6 +21,10 @@ package org.jclouds.demo.tweetstore.integration; import static com.google.common.base.Preconditions.checkNotNull; import static org.jclouds.demo.tweetstore.reference.TweetStoreConstants.PROPERTY_TWEETSTORE_BLOBSTORES; import static org.jclouds.demo.tweetstore.reference.TweetStoreConstants.PROPERTY_TWEETSTORE_CONTAINER; +import static org.jclouds.demo.tweetstore.reference.TwitterConstants.PROPERTY_TWITTER_ACCESSTOKEN; +import static org.jclouds.demo.tweetstore.reference.TwitterConstants.PROPERTY_TWITTER_ACCESSTOKEN_SECRET; +import static org.jclouds.demo.tweetstore.reference.TwitterConstants.PROPERTY_TWITTER_CONSUMER_KEY; +import static org.jclouds.demo.tweetstore.reference.TwitterConstants.PROPERTY_TWITTER_CONSUMER_SECRET; import java.io.IOException; import java.io.InputStream; @@ -99,10 +103,10 @@ public class TweetStoreLiveTest { } Configuration conf = new ConfigurationBuilder() - .setOAuthConsumerKey(props.getProperty(TwitterConstants.PROPERTY_TWITTER_CONSUMER_KEY)) - .setOAuthConsumerSecret(props.getProperty(TwitterConstants.PROPERTY_TWITTER_CONSUMER_SECRET)) - .setOAuthAccessToken(props.getProperty(TwitterConstants.PROPERTY_TWITTER_ACCESSTOKEN)) - .setOAuthAccessTokenSecret(props.getProperty(TwitterConstants.PROPERTY_TWITTER_ACCESSTOKEN_SECRET)) + .setOAuthConsumerKey(props.getProperty(PROPERTY_TWITTER_CONSUMER_KEY)) + .setOAuthConsumerSecret(props.getProperty(PROPERTY_TWITTER_CONSUMER_SECRET)) + .setOAuthAccessToken(props.getProperty(PROPERTY_TWITTER_ACCESSTOKEN)) + .setOAuthAccessTokenSecret(props.getProperty(PROPERTY_TWITTER_ACCESSTOKEN_SECRET)) .build(); Twitter client = new TwitterFactory(conf).getInstance(); StoreTweetsController controller = new StoreTweetsController(contexts, container, client); @@ -148,14 +152,14 @@ public class TweetStoreLiveTest { } private void addConfigurationForTwitter(Properties props) { - props.setProperty(TwitterConstants.PROPERTY_TWITTER_CONSUMER_KEY, - getRequiredSystemProperty("test." + TwitterConstants.PROPERTY_TWITTER_CONSUMER_KEY)); - props.setProperty(TwitterConstants.PROPERTY_TWITTER_CONSUMER_SECRET, - getRequiredSystemProperty("test." + TwitterConstants.PROPERTY_TWITTER_CONSUMER_SECRET)); - props.setProperty(TwitterConstants.PROPERTY_TWITTER_ACCESSTOKEN, - getRequiredSystemProperty("test." + TwitterConstants.PROPERTY_TWITTER_ACCESSTOKEN)); - props.setProperty(TwitterConstants.PROPERTY_TWITTER_ACCESSTOKEN_SECRET, - getRequiredSystemProperty("test." + TwitterConstants.PROPERTY_TWITTER_ACCESSTOKEN_SECRET)); + props.setProperty(PROPERTY_TWITTER_CONSUMER_KEY, + getRequiredSystemProperty("test." + PROPERTY_TWITTER_CONSUMER_KEY)); + props.setProperty(PROPERTY_TWITTER_CONSUMER_SECRET, + getRequiredSystemProperty("test." + PROPERTY_TWITTER_CONSUMER_SECRET)); + props.setProperty(PROPERTY_TWITTER_ACCESSTOKEN, + getRequiredSystemProperty("test." + PROPERTY_TWITTER_ACCESSTOKEN)); + props.setProperty(PROPERTY_TWITTER_ACCESSTOKEN_SECRET, + getRequiredSystemProperty("test." + PROPERTY_TWITTER_ACCESSTOKEN_SECRET)); } private void addCredentialsForBlobStores(Properties props) { @@ -225,11 +229,4 @@ public class TweetStoreLiveTest { String string = Strings2.toStringAndClose(i); assert string.indexOf("Tweets in Clouds") >= 0 : string; } - - private static interface TwitterConstants { - static final String PROPERTY_TWITTER_CONSUMER_KEY = "twitter.consumer.identity"; - static final String PROPERTY_TWITTER_CONSUMER_SECRET = "twitter.consumer.credential"; - static final String PROPERTY_TWITTER_ACCESSTOKEN = "twitter.access.identity"; - static final String PROPERTY_TWITTER_ACCESSTOKEN_SECRET = "twitter.access.credential"; - } } diff --git a/demos/tweetstore/runatcloud-tweetstore/src/main/java/org/jclouds/demo/tweetstore/config/GuiceServletConfig.java b/demos/tweetstore/runatcloud-tweetstore/src/main/java/org/jclouds/demo/tweetstore/config/GuiceServletConfig.java index 3af47b0c2f..93c9972ad6 100644 --- a/demos/tweetstore/runatcloud-tweetstore/src/main/java/org/jclouds/demo/tweetstore/config/GuiceServletConfig.java +++ b/demos/tweetstore/runatcloud-tweetstore/src/main/java/org/jclouds/demo/tweetstore/config/GuiceServletConfig.java @@ -21,6 +21,10 @@ package org.jclouds.demo.tweetstore.config; import static com.google.common.base.Preconditions.checkNotNull; import static java.util.concurrent.TimeUnit.MINUTES; import static org.jclouds.demo.tweetstore.reference.TweetStoreConstants.PROPERTY_TWEETSTORE_CONTAINER; +import static org.jclouds.demo.tweetstore.reference.TwitterConstants.PROPERTY_TWITTER_ACCESSTOKEN; +import static org.jclouds.demo.tweetstore.reference.TwitterConstants.PROPERTY_TWITTER_ACCESSTOKEN_SECRET; +import static org.jclouds.demo.tweetstore.reference.TwitterConstants.PROPERTY_TWITTER_CONSUMER_KEY; +import static org.jclouds.demo.tweetstore.reference.TwitterConstants.PROPERTY_TWITTER_CONSUMER_SECRET; import java.io.IOException; import java.io.InputStream; @@ -81,12 +85,14 @@ public class GuiceServletConfig extends GuiceServletContextListener { // shared across all blobstores and used to retrieve tweets try { Configuration twitterConf = new ConfigurationBuilder() - .setUser(props.getProperty("twitter.identity")) - .setPassword(props.getProperty("twitter.credential")).build(); + .setOAuthConsumerKey(props.getProperty(PROPERTY_TWITTER_CONSUMER_KEY)) + .setOAuthConsumerSecret(props.getProperty(PROPERTY_TWITTER_CONSUMER_SECRET)) + .setOAuthAccessToken(props.getProperty(PROPERTY_TWITTER_ACCESSTOKEN)) + .setOAuthAccessTokenSecret(props.getProperty(PROPERTY_TWITTER_ACCESSTOKEN_SECRET)) + .build(); twitterClient = new TwitterFactory(twitterConf).getInstance(); } catch (IllegalArgumentException e) { - throw new IllegalArgumentException("properties for twitter not configured properly in " - + props.toString(), e); + throw new IllegalArgumentException("properties for twitter not configured properly in " + props.toString(), e); } // common namespace for storing tweets container = checkNotNull(props.getProperty(PROPERTY_TWEETSTORE_CONTAINER), PROPERTY_TWEETSTORE_CONTAINER); diff --git a/demos/tweetstore/runatcloud-tweetstore/src/main/java/org/jclouds/demo/tweetstore/reference/TwitterConstants.java b/demos/tweetstore/runatcloud-tweetstore/src/main/java/org/jclouds/demo/tweetstore/reference/TwitterConstants.java new file mode 100644 index 0000000000..0075a27976 --- /dev/null +++ b/demos/tweetstore/runatcloud-tweetstore/src/main/java/org/jclouds/demo/tweetstore/reference/TwitterConstants.java @@ -0,0 +1,31 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.jclouds.demo.tweetstore.reference; + +/** + * Configuration properties and constants used in Twitter connections. + * + * @author Andrew Phillips + */ +public interface TwitterConstants { + static final String PROPERTY_TWITTER_CONSUMER_KEY = "twitter.consumer.identity"; + static final String PROPERTY_TWITTER_CONSUMER_SECRET = "twitter.consumer.credential"; + static final String PROPERTY_TWITTER_ACCESSTOKEN = "twitter.access.identity"; + static final String PROPERTY_TWITTER_ACCESSTOKEN_SECRET = "twitter.access.credential"; +} diff --git a/demos/tweetstore/runatcloud-tweetstore/src/test/java/org/jclouds/demo/tweetstore/integration/TweetStoreLiveTest.java b/demos/tweetstore/runatcloud-tweetstore/src/test/java/org/jclouds/demo/tweetstore/integration/TweetStoreLiveTest.java index f0a837be91..929537c037 100644 --- a/demos/tweetstore/runatcloud-tweetstore/src/test/java/org/jclouds/demo/tweetstore/integration/TweetStoreLiveTest.java +++ b/demos/tweetstore/runatcloud-tweetstore/src/test/java/org/jclouds/demo/tweetstore/integration/TweetStoreLiveTest.java @@ -21,6 +21,10 @@ package org.jclouds.demo.tweetstore.integration; import static com.google.common.base.Preconditions.checkNotNull; import static org.jclouds.demo.tweetstore.reference.TweetStoreConstants.PROPERTY_TWEETSTORE_BLOBSTORES; import static org.jclouds.demo.tweetstore.reference.TweetStoreConstants.PROPERTY_TWEETSTORE_CONTAINER; +import static org.jclouds.demo.tweetstore.reference.TwitterConstants.PROPERTY_TWITTER_ACCESSTOKEN; +import static org.jclouds.demo.tweetstore.reference.TwitterConstants.PROPERTY_TWITTER_ACCESSTOKEN_SECRET; +import static org.jclouds.demo.tweetstore.reference.TwitterConstants.PROPERTY_TWITTER_CONSUMER_KEY; +import static org.jclouds.demo.tweetstore.reference.TwitterConstants.PROPERTY_TWITTER_CONSUMER_SECRET; import java.io.IOException; import java.io.InputStream; @@ -100,10 +104,10 @@ public class TweetStoreLiveTest { } Configuration conf = new ConfigurationBuilder() - .setOAuthConsumerKey(props.getProperty(TwitterConstants.PROPERTY_TWITTER_CONSUMER_KEY)) - .setOAuthConsumerSecret(props.getProperty(TwitterConstants.PROPERTY_TWITTER_CONSUMER_SECRET)) - .setOAuthAccessToken(props.getProperty(TwitterConstants.PROPERTY_TWITTER_ACCESSTOKEN)) - .setOAuthAccessTokenSecret(props.getProperty(TwitterConstants.PROPERTY_TWITTER_ACCESSTOKEN_SECRET)) + .setOAuthConsumerKey(props.getProperty(PROPERTY_TWITTER_CONSUMER_KEY)) + .setOAuthConsumerSecret(props.getProperty(PROPERTY_TWITTER_CONSUMER_SECRET)) + .setOAuthAccessToken(props.getProperty(PROPERTY_TWITTER_ACCESSTOKEN)) + .setOAuthAccessTokenSecret(props.getProperty(PROPERTY_TWITTER_ACCESSTOKEN_SECRET)) .build(); Twitter client = new TwitterFactory(conf).getInstance(); StoreTweetsController controller = new StoreTweetsController(contexts, container, client); @@ -149,14 +153,14 @@ public class TweetStoreLiveTest { } private void addConfigurationForTwitter(Properties props) { - props.setProperty(TwitterConstants.PROPERTY_TWITTER_CONSUMER_KEY, - getRequiredSystemProperty("test." + TwitterConstants.PROPERTY_TWITTER_CONSUMER_KEY)); - props.setProperty(TwitterConstants.PROPERTY_TWITTER_CONSUMER_SECRET, - getRequiredSystemProperty("test." + TwitterConstants.PROPERTY_TWITTER_CONSUMER_SECRET)); - props.setProperty(TwitterConstants.PROPERTY_TWITTER_ACCESSTOKEN, - getRequiredSystemProperty("test." + TwitterConstants.PROPERTY_TWITTER_ACCESSTOKEN)); - props.setProperty(TwitterConstants.PROPERTY_TWITTER_ACCESSTOKEN_SECRET, - getRequiredSystemProperty("test." + TwitterConstants.PROPERTY_TWITTER_ACCESSTOKEN_SECRET)); + props.setProperty(PROPERTY_TWITTER_CONSUMER_KEY, + getRequiredSystemProperty("test." + PROPERTY_TWITTER_CONSUMER_KEY)); + props.setProperty(PROPERTY_TWITTER_CONSUMER_SECRET, + getRequiredSystemProperty("test." + PROPERTY_TWITTER_CONSUMER_SECRET)); + props.setProperty(PROPERTY_TWITTER_ACCESSTOKEN, + getRequiredSystemProperty("test." + PROPERTY_TWITTER_ACCESSTOKEN)); + props.setProperty(PROPERTY_TWITTER_ACCESSTOKEN_SECRET, + getRequiredSystemProperty("test." + PROPERTY_TWITTER_ACCESSTOKEN_SECRET)); } private void addCredentialsForBlobStores(Properties props) { @@ -228,11 +232,4 @@ public class TweetStoreLiveTest { String string = Strings2.toStringAndClose(i); assert string.indexOf("Tweets in Clouds") >= 0 : string; } - - private static interface TwitterConstants { - static final String PROPERTY_TWITTER_CONSUMER_KEY = "twitter.consumer.identity"; - static final String PROPERTY_TWITTER_CONSUMER_SECRET = "twitter.consumer.credential"; - static final String PROPERTY_TWITTER_ACCESSTOKEN = "twitter.access.identity"; - static final String PROPERTY_TWITTER_ACCESSTOKEN_SECRET = "twitter.access.credential"; - } } From 4cd17db5232308262316fd94d8cb1cb8deb38ea5 Mon Sep 17 00:00:00 2001 From: Andrew Phillips Date: Fri, 3 Jun 2011 03:07:21 +0200 Subject: [PATCH 038/264] Added a 'tweetstore.instance' identifier to fetch the correct jclouds.properties remote resource bundle --- demos/tweetstore/gae-tweetstore-spring/pom.xml | 4 ++++ demos/tweetstore/gae-tweetstore/pom.xml | 4 ++++ demos/tweetstore/pom.xml | 3 ++- demos/tweetstore/runatcloud-tweetstore/pom.xml | 4 ++++ 4 files changed, 14 insertions(+), 1 deletion(-) diff --git a/demos/tweetstore/gae-tweetstore-spring/pom.xml b/demos/tweetstore/gae-tweetstore-spring/pom.xml index 229e937bcc..7098814889 100644 --- a/demos/tweetstore/gae-tweetstore-spring/pom.xml +++ b/demos/tweetstore/gae-tweetstore-spring/pom.xml @@ -209,6 +209,10 @@ deploy + + + gae-tweetstore-spring + diff --git a/demos/tweetstore/gae-tweetstore/pom.xml b/demos/tweetstore/gae-tweetstore/pom.xml index 77042cfd5a..142189e77b 100644 --- a/demos/tweetstore/gae-tweetstore/pom.xml +++ b/demos/tweetstore/gae-tweetstore/pom.xml @@ -195,6 +195,10 @@ deploy + + + gae-tweetstore + diff --git a/demos/tweetstore/pom.xml b/demos/tweetstore/pom.xml index 404c2441a6..2b9bb2dda9 100644 --- a/demos/tweetstore/pom.xml +++ b/demos/tweetstore/pom.xml @@ -168,7 +168,8 @@ - org.jclouds:jclouds-properties:${project.version} + + ${project.groupId}:jclouds-demos-tweetstore-jclouds-properties:${project.version}.${tweetstore.instance} diff --git a/demos/tweetstore/runatcloud-tweetstore/pom.xml b/demos/tweetstore/runatcloud-tweetstore/pom.xml index 913462f58e..0a2031c9dc 100644 --- a/demos/tweetstore/runatcloud-tweetstore/pom.xml +++ b/demos/tweetstore/runatcloud-tweetstore/pom.xml @@ -190,6 +190,10 @@ deploy + + + runatcloud-tweetstore + bees-plugins-snapshots From 14bfc83d69c0b6bad25079110cd60ee2dbfb28e6 Mon Sep 17 00:00:00 2001 From: Gustavo Morozowski Date: Thu, 2 Jun 2011 22:28:40 -0300 Subject: [PATCH 039/264] Issue 550: Added ProviderMetaData for Serverlove. --- .../ServerloveManchesterProviderMetadata.java | 115 ++++++++++++++++++ .../org.jclouds.providers.ProviderMetadata | 1 + .../ServerloveManchesterProviderTest.java | 35 ++++++ 3 files changed, 151 insertions(+) create mode 100644 providers/serverlove-z1-man/src/main/java/org/jclouds/serverlove/ServerloveManchesterProviderMetadata.java create mode 100644 providers/serverlove-z1-man/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata create mode 100644 providers/serverlove-z1-man/src/test/java/org/jclouds/serverlove/ServerloveManchesterProviderTest.java diff --git a/providers/serverlove-z1-man/src/main/java/org/jclouds/serverlove/ServerloveManchesterProviderMetadata.java b/providers/serverlove-z1-man/src/main/java/org/jclouds/serverlove/ServerloveManchesterProviderMetadata.java new file mode 100644 index 0000000000..87d8dd74eb --- /dev/null +++ b/providers/serverlove-z1-man/src/main/java/org/jclouds/serverlove/ServerloveManchesterProviderMetadata.java @@ -0,0 +1,115 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.jclouds.serverlove; + +import com.google.common.collect.ImmutableSet; + +import java.net.URI; +import java.util.Set; + +import org.jclouds.providers.BaseProviderMetadata; +import org.jclouds.providers.ProviderMetadata; + +/** + * Implementation of {@link org.jclouds.types.ProviderMetadata} for Serverlove Manchester. + * + * @author Adrian Cole + */ +public class ServerloveManchesterProviderMetadata extends BaseProviderMetadata { + + /** + * {@inheritDoc} + */ + @Override + public String getId() { + return "serverlove-z1-man"; + } + + /** + * {@inheritDoc} + */ + @Override + public String getType() { + return ProviderMetadata.COMPUTE_TYPE; + } + + /** + * {@inheritDoc} + */ + @Override + public String getName() { + return "Serverlove Manchester"; + } + + /** + * {@inheritDoc} + */ + @Override + public String getIdentityName() { + return "UUID"; + } + + /** + * {@inheritDoc} + */ + @Override + public String getCredentialName() { + return "Secret API Key"; + } + + /** + * {@inheritDoc} + */ + @Override + public URI getHomepage() { + return URI.create("http://www.serverlove.com"); + } + + /** + * {@inheritDoc} + */ + @Override + public URI getConsole() { + return URI.create("http://www.serverlove.com/login"); + } + /** + * {@inheritDoc} + */ + @Override + public URI getApiDocumentation() { + return URI.create("http://www.serverlove.com/cloud-server-faqs/api-questions"); + } + + /** + * {@inheritDoc} + */ + @Override + public Set getLinkedServices() { + return ImmutableSet.of("serverlove-z1-man"); + } + + /** + * {@inheritDoc} + */ + @Override + public Set getIso3166Codes() { + return ImmutableSet.of("GB-MAN"); + } + +} diff --git a/providers/serverlove-z1-man/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata b/providers/serverlove-z1-man/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata new file mode 100644 index 0000000000..f50adb3764 --- /dev/null +++ b/providers/serverlove-z1-man/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata @@ -0,0 +1 @@ +org.jclouds.serverlove.ServerloveManchesterProviderMetadata diff --git a/providers/serverlove-z1-man/src/test/java/org/jclouds/serverlove/ServerloveManchesterProviderTest.java b/providers/serverlove-z1-man/src/test/java/org/jclouds/serverlove/ServerloveManchesterProviderTest.java new file mode 100644 index 0000000000..725c8fe7ce --- /dev/null +++ b/providers/serverlove-z1-man/src/test/java/org/jclouds/serverlove/ServerloveManchesterProviderTest.java @@ -0,0 +1,35 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.jclouds.serverlove; + +import org.jclouds.providers.BaseProviderMetadataTest; +import org.jclouds.providers.ProviderMetadata; +import org.testng.annotations.Test; + +/** + * + * @author Adrian Cole + */ +@Test(groups = "unit", testName = "ServerloveManchesterProviderTest") +public class ServerloveManchesterProviderTest extends BaseProviderMetadataTest { + + public ServerloveManchesterProviderTest() { + super(new ServerloveManchesterProviderMetadata(), ProviderMetadata.COMPUTE_TYPE); + } +} From d313950f38ff3aa58022fcd2b76a10cb92db129b Mon Sep 17 00:00:00 2001 From: Gustavo Morozowski Date: Thu, 2 Jun 2011 22:57:07 -0300 Subject: [PATCH 040/264] Issue 550: Added ProviderMetaData for SkaliCloud. --- .../SkaliCloudMalaysiaProviderMetadata.java | 115 ++++++++++++++++++ .../org.jclouds.providers.ProviderMetadata | 1 + .../SkaliCloudMalasyaProviderTest.java | 35 ++++++ 3 files changed, 151 insertions(+) create mode 100644 providers/skalicloud-sdg-my/src/main/java/org/jclouds/skalicloud/SkaliCloudMalaysiaProviderMetadata.java create mode 100644 providers/skalicloud-sdg-my/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata create mode 100644 providers/skalicloud-sdg-my/src/test/java/org/jclouds/skalicloud/SkaliCloudMalasyaProviderTest.java diff --git a/providers/skalicloud-sdg-my/src/main/java/org/jclouds/skalicloud/SkaliCloudMalaysiaProviderMetadata.java b/providers/skalicloud-sdg-my/src/main/java/org/jclouds/skalicloud/SkaliCloudMalaysiaProviderMetadata.java new file mode 100644 index 0000000000..59dc92fa02 --- /dev/null +++ b/providers/skalicloud-sdg-my/src/main/java/org/jclouds/skalicloud/SkaliCloudMalaysiaProviderMetadata.java @@ -0,0 +1,115 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.jclouds.skalicloud; + +import com.google.common.collect.ImmutableSet; + +import java.net.URI; +import java.util.Set; + +import org.jclouds.providers.BaseProviderMetadata; +import org.jclouds.providers.ProviderMetadata; + +/** + * Implementation of {@link org.jclouds.types.ProviderMetadata} for SkaliCloud Malasya. + * + * @author Adrian Cole + */ +public class SkaliCloudMalaysiaProviderMetadata extends BaseProviderMetadata { + + /** + * {@inheritDoc} + */ + @Override + public String getId() { + return "skalicloud-sdg-my"; + } + + /** + * {@inheritDoc} + */ + @Override + public String getType() { + return ProviderMetadata.COMPUTE_TYPE; + } + + /** + * {@inheritDoc} + */ + @Override + public String getName() { + return "ElasticHosts London Peer 1"; + } + + /** + * {@inheritDoc} + */ + @Override + public String getIdentityName() { + return "UUID"; + } + + /** + * {@inheritDoc} + */ + @Override + public String getCredentialName() { + return "Secret API Key"; + } + + /** + * {@inheritDoc} + */ + @Override + public URI getHomepage() { + return URI.create("http://www.skalicloud.com"); + } + + /** + * {@inheritDoc} + */ + @Override + public URI getConsole() { + return URI.create("http://sdg-my.skalicloud.com"); + } + /** + * {@inheritDoc} + */ + @Override + public URI getApiDocumentation() { + return URI.create("http://www.skalicloud.com/cloud-api"); + } + + /** + * {@inheritDoc} + */ + @Override + public Set getLinkedServices() { + return ImmutableSet.of("skalicloud-sdg-my"); + } + + /** + * {@inheritDoc} + */ + @Override + public Set getIso3166Codes() { + return ImmutableSet.of("MY-10"); + } + +} diff --git a/providers/skalicloud-sdg-my/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata b/providers/skalicloud-sdg-my/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata new file mode 100644 index 0000000000..bb9797a8fe --- /dev/null +++ b/providers/skalicloud-sdg-my/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata @@ -0,0 +1 @@ +org.jclouds.skalicloud.SkaliCloudMalaysiaProviderMetadata diff --git a/providers/skalicloud-sdg-my/src/test/java/org/jclouds/skalicloud/SkaliCloudMalasyaProviderTest.java b/providers/skalicloud-sdg-my/src/test/java/org/jclouds/skalicloud/SkaliCloudMalasyaProviderTest.java new file mode 100644 index 0000000000..fb703e4d03 --- /dev/null +++ b/providers/skalicloud-sdg-my/src/test/java/org/jclouds/skalicloud/SkaliCloudMalasyaProviderTest.java @@ -0,0 +1,35 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.jclouds.skalicloud; + +import org.jclouds.providers.BaseProviderMetadataTest; +import org.jclouds.providers.ProviderMetadata; +import org.testng.annotations.Test; + +/** + * + * @author Adrian Cole + */ +@Test(groups = "unit", testName = "SkaliCloudMalaysiaProviderTest") +public class SkaliCloudMalasyaProviderTest extends BaseProviderMetadataTest { + + public SkaliCloudMalasyaProviderTest() { + super(new SkaliCloudMalaysiaProviderMetadata(), ProviderMetadata.COMPUTE_TYPE); + } +} From 226efe0659f41024916f5db2b73b6075f198dc4f Mon Sep 17 00:00:00 2001 From: Gustavo Morozowski Date: Thu, 2 Jun 2011 23:20:38 -0300 Subject: [PATCH 041/264] Issue 550: Added ProviderMetaData for RimuHosting. --- .../miro/RimuHostingProviderMetadata.java | 115 ++++++++++++++++++ .../org.jclouds.providers.ProviderMetadata | 1 + .../miro/RimuHostingProviderTest.java | 35 ++++++ .../SkaliCloudMalaysiaProviderMetadata.java | 2 +- 4 files changed, 152 insertions(+), 1 deletion(-) create mode 100644 providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/RimuHostingProviderMetadata.java create mode 100644 providers/rimuhosting/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata create mode 100644 providers/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/RimuHostingProviderTest.java diff --git a/providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/RimuHostingProviderMetadata.java b/providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/RimuHostingProviderMetadata.java new file mode 100644 index 0000000000..eba194ade7 --- /dev/null +++ b/providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/RimuHostingProviderMetadata.java @@ -0,0 +1,115 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.jclouds.rimuhosting.miro; + +import com.google.common.collect.ImmutableSet; + +import java.net.URI; +import java.util.Set; + +import org.jclouds.providers.BaseProviderMetadata; +import org.jclouds.providers.ProviderMetadata; + +/** + * Implementation of {@link org.jclouds.types.ProviderMetadata} for RimuHosting. + * + * @author Adrian Cole + */ +public class RimuHostingProviderMetadata extends BaseProviderMetadata { + + /** + * {@inheritDoc} + */ + @Override + public String getId() { + return "rimuhosting"; + } + + /** + * {@inheritDoc} + */ + @Override + public String getType() { + return ProviderMetadata.COMPUTE_TYPE; + } + + /** + * {@inheritDoc} + */ + @Override + public String getName() { + return "RimuHosting"; + } + + /** + * {@inheritDoc} + */ + @Override + public String getIdentityName() { + return "UUID"; + } + + /** + * {@inheritDoc} + */ + @Override + public String getCredentialName() { + return "Secret API Key"; + } + + /** + * {@inheritDoc} + */ + @Override + public URI getHomepage() { + return URI.create("http://rimuhosting.com"); + } + + /** + * {@inheritDoc} + */ + @Override + public URI getConsole() { + return URI.create("https://rimuhosting.com/cp"); + } + /** + * {@inheritDoc} + */ + @Override + public URI getApiDocumentation() { + return URI.create("http://apidocs.rimuhosting.com"); + } + + /** + * {@inheritDoc} + */ + @Override + public Set getLinkedServices() { + return ImmutableSet.of("rimuhosting"); + } + + /** + * {@inheritDoc} + */ + @Override + public Set getIso3166Codes() { + return ImmutableSet.of("NZ-AUK", "US-TX", "AU-NSW", "GB-LND"); + } + +} diff --git a/providers/rimuhosting/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata b/providers/rimuhosting/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata new file mode 100644 index 0000000000..b3a6e93521 --- /dev/null +++ b/providers/rimuhosting/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata @@ -0,0 +1 @@ +org.jclouds.rimuhosting.miro.RimuHostingProviderMetadata diff --git a/providers/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/RimuHostingProviderTest.java b/providers/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/RimuHostingProviderTest.java new file mode 100644 index 0000000000..7361a28ceb --- /dev/null +++ b/providers/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/RimuHostingProviderTest.java @@ -0,0 +1,35 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.jclouds.rimuhosting.miro; + +import org.jclouds.providers.BaseProviderMetadataTest; +import org.jclouds.providers.ProviderMetadata; +import org.testng.annotations.Test; + +/** + * + * @author Adrian Cole + */ +@Test(groups = "unit", testName = "RimuHostingProviderTest") +public class RimuHostingProviderTest extends BaseProviderMetadataTest { + + public RimuHostingProviderTest() { + super(new RimuHostingProviderMetadata(), ProviderMetadata.COMPUTE_TYPE); + } +} diff --git a/providers/skalicloud-sdg-my/src/main/java/org/jclouds/skalicloud/SkaliCloudMalaysiaProviderMetadata.java b/providers/skalicloud-sdg-my/src/main/java/org/jclouds/skalicloud/SkaliCloudMalaysiaProviderMetadata.java index 59dc92fa02..f6db1a1553 100644 --- a/providers/skalicloud-sdg-my/src/main/java/org/jclouds/skalicloud/SkaliCloudMalaysiaProviderMetadata.java +++ b/providers/skalicloud-sdg-my/src/main/java/org/jclouds/skalicloud/SkaliCloudMalaysiaProviderMetadata.java @@ -54,7 +54,7 @@ public class SkaliCloudMalaysiaProviderMetadata extends BaseProviderMetadata { */ @Override public String getName() { - return "ElasticHosts London Peer 1"; + return "SkaliCloud Malasya"; } /** From 9ef411d39ac84ba9e239e127dac93ad45da5a3ac Mon Sep 17 00:00:00 2001 From: Adrian Cole Date: Thu, 2 Jun 2011 19:57:55 -0700 Subject: [PATCH 042/264] added debian 6 to bluesquare --- .../resources/elastichosts-lon-b/preinstalled_images.json | 7 +++++++ ...ElasticHostsBlueSquareLondonComputeServiceLiveTest.java | 2 +- ...lasticHostsBlueSquareLondonTemplateBuilderLiveTest.java | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/providers/elastichosts-lon-b/src/main/resources/elastichosts-lon-b/preinstalled_images.json b/providers/elastichosts-lon-b/src/main/resources/elastichosts-lon-b/preinstalled_images.json index dadd7b7441..41b2f33605 100644 --- a/providers/elastichosts-lon-b/src/main/resources/elastichosts-lon-b/preinstalled_images.json +++ b/providers/elastichosts-lon-b/src/main/resources/elastichosts-lon-b/preinstalled_images.json @@ -13,6 +13,13 @@ "osVersion": "5.0", "size": "1" }, + { + "uuid": "6aa953cc-3395-4e8d-938e-65c74fd20334", + "description": "Debian Linux 6.0.1", + "osFamily": "DEBIAN", + "osVersion": "6.0", + "size": "1" + }, { "uuid": "aee5589a-88c3-43ef-bb0a-9cab6e64192d", "description": "Ubuntu Linux 10.04", diff --git a/providers/elastichosts-lon-b/src/test/java/org/jclouds/elastichosts/compute/ElasticHostsBlueSquareLondonComputeServiceLiveTest.java b/providers/elastichosts-lon-b/src/test/java/org/jclouds/elastichosts/compute/ElasticHostsBlueSquareLondonComputeServiceLiveTest.java index 16870c87c3..a679bc4a23 100644 --- a/providers/elastichosts-lon-b/src/test/java/org/jclouds/elastichosts/compute/ElasticHostsBlueSquareLondonComputeServiceLiveTest.java +++ b/providers/elastichosts-lon-b/src/test/java/org/jclouds/elastichosts/compute/ElasticHostsBlueSquareLondonComputeServiceLiveTest.java @@ -25,7 +25,7 @@ import org.testng.annotations.Test; * * @author Adrian Cole */ -@Test(groups = "live", sequential = true, testName = "ElasticHostsBlueSquareLondonComputeServiceLiveTest") +@Test(groups = "live", singleThreaded = true, testName = "ElasticHostsBlueSquareLondonComputeServiceLiveTest") public class ElasticHostsBlueSquareLondonComputeServiceLiveTest extends ElasticStackComputeServiceLiveTest { public ElasticHostsBlueSquareLondonComputeServiceLiveTest() { diff --git a/providers/elastichosts-lon-b/src/test/java/org/jclouds/elastichosts/compute/ElasticHostsBlueSquareLondonTemplateBuilderLiveTest.java b/providers/elastichosts-lon-b/src/test/java/org/jclouds/elastichosts/compute/ElasticHostsBlueSquareLondonTemplateBuilderLiveTest.java index 1949cdb152..a727e53fe4 100644 --- a/providers/elastichosts-lon-b/src/test/java/org/jclouds/elastichosts/compute/ElasticHostsBlueSquareLondonTemplateBuilderLiveTest.java +++ b/providers/elastichosts-lon-b/src/test/java/org/jclouds/elastichosts/compute/ElasticHostsBlueSquareLondonTemplateBuilderLiveTest.java @@ -54,7 +54,7 @@ public class ElasticHostsBlueSquareLondonTemplateBuilderLiveTest extends BaseTem case UBUNTU: return (input.version.equals("") || input.version.equals("10.04")) && input.is64Bit; case DEBIAN: - return (input.version.equals("") || input.version.equals("5.0")) && input.is64Bit; + return (input.version.equals("") || input.version.matches("[56].0")) && input.is64Bit; case CENTOS: return (input.version.equals("") || input.version.equals("5.5")) && input.is64Bit; case WINDOWS: From cfe91f9817c51324d78d8912ada5fb6f6bf4b6bc Mon Sep 17 00:00:00 2001 From: Kedar Dave Date: Thu, 2 Jun 2011 22:25:34 -0500 Subject: [PATCH 043/264] added test dependency --- .../java/org/jclouds/savvis/vpdc/features/VMClientLiveTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/providers/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/features/VMClientLiveTest.java b/providers/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/features/VMClientLiveTest.java index ecbf493449..db58130890 100644 --- a/providers/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/features/VMClientLiveTest.java +++ b/providers/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/features/VMClientLiveTest.java @@ -131,7 +131,7 @@ public class VMClientLiveTest extends BaseVPDCClientLiveTest { // conditionallyCheckSSH(); } - @Test + @Test(dependsOnMethods="testCloneVApp") public void testZCreateMultipleVMs() throws Exception { billingSiteId = restContext.getApi().getBrowsingClient().getOrg(null).getId();// default vpdcId = Iterables.find(restContext.getApi().getBrowsingClient().getOrg(billingSiteId).getVDCs(), From 424184c380842f4df17a21b459ac65d09f6b77de Mon Sep 17 00:00:00 2001 From: Adrian Cole Date: Thu, 2 Jun 2011 20:32:03 -0700 Subject: [PATCH 044/264] Issue 594: move google storage back to sandbox --- README.txt | 4 ++-- allblobstore/pom.xml | 5 ----- providers/pom.xml | 1 - {providers => sandbox-providers}/googlestorage/README.txt | 0 {providers => sandbox-providers}/googlestorage/pom.xml | 0 .../org/jclouds/googlestorage/GoogleStorageAsyncClient.java | 0 .../jclouds/googlestorage/GoogleStorageContextBuilder.java | 0 .../googlestorage/GoogleStoragePropertiesBuilder.java | 0 .../jclouds/googlestorage/GoogleStorageProviderMetadata.java | 0 .../binders/BindGoogleStorageObjectMetadataToRequest.java | 0 .../googlestorage/config/GoogleStorageRestClientModule.java | 0 .../META-INF/services/org.jclouds.providers.ProviderMetadata | 0 .../googlestorage/GoogleStorageAsyncClientTestDisabled.java | 0 .../jclouds/googlestorage/GoogleStorageClientLiveTest.java | 0 .../org/jclouds/googlestorage/GoogleStorageProviderTest.java | 0 .../BindGoogleStorageObjectMetadataToRequestTest.java | 0 .../blobstore/GoogleStorageBlobIntegrationLiveTest.java | 0 .../googlestorage/blobstore/GoogleStorageBlobLiveTest.java | 0 .../blobstore/GoogleStorageBlobMapIntegrationLiveTest.java | 0 .../blobstore/GoogleStorageBlobSignerLiveTest.java | 0 .../blobstore/GoogleStorageContainerIntegrationLiveTest.java | 0 .../blobstore/GoogleStorageContainerLiveTest.java | 0 .../GoogleStorageInputStreamMapIntegrationLiveTest.java | 0 .../blobstore/GoogleStorageServiceIntegrationLiveTest.java | 0 .../blobstore/GoogleStorageTestInitializer.java | 0 25 files changed, 2 insertions(+), 8 deletions(-) rename {providers => sandbox-providers}/googlestorage/README.txt (100%) rename {providers => sandbox-providers}/googlestorage/pom.xml (100%) rename {providers => sandbox-providers}/googlestorage/src/main/java/org/jclouds/googlestorage/GoogleStorageAsyncClient.java (100%) rename {providers => sandbox-providers}/googlestorage/src/main/java/org/jclouds/googlestorage/GoogleStorageContextBuilder.java (100%) rename {providers => sandbox-providers}/googlestorage/src/main/java/org/jclouds/googlestorage/GoogleStoragePropertiesBuilder.java (100%) rename {providers => sandbox-providers}/googlestorage/src/main/java/org/jclouds/googlestorage/GoogleStorageProviderMetadata.java (100%) rename {providers => sandbox-providers}/googlestorage/src/main/java/org/jclouds/googlestorage/binders/BindGoogleStorageObjectMetadataToRequest.java (100%) rename {providers => sandbox-providers}/googlestorage/src/main/java/org/jclouds/googlestorage/config/GoogleStorageRestClientModule.java (100%) rename {providers => sandbox-providers}/googlestorage/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata (100%) rename {providers => sandbox-providers}/googlestorage/src/test/java/org/jclouds/googlestorage/GoogleStorageAsyncClientTestDisabled.java (100%) rename {providers => sandbox-providers}/googlestorage/src/test/java/org/jclouds/googlestorage/GoogleStorageClientLiveTest.java (100%) rename {providers => sandbox-providers}/googlestorage/src/test/java/org/jclouds/googlestorage/GoogleStorageProviderTest.java (100%) rename {providers => sandbox-providers}/googlestorage/src/test/java/org/jclouds/googlestorage/binders/BindGoogleStorageObjectMetadataToRequestTest.java (100%) rename {providers => sandbox-providers}/googlestorage/src/test/java/org/jclouds/googlestorage/blobstore/GoogleStorageBlobIntegrationLiveTest.java (100%) rename {providers => sandbox-providers}/googlestorage/src/test/java/org/jclouds/googlestorage/blobstore/GoogleStorageBlobLiveTest.java (100%) rename {providers => sandbox-providers}/googlestorage/src/test/java/org/jclouds/googlestorage/blobstore/GoogleStorageBlobMapIntegrationLiveTest.java (100%) rename {providers => sandbox-providers}/googlestorage/src/test/java/org/jclouds/googlestorage/blobstore/GoogleStorageBlobSignerLiveTest.java (100%) rename {providers => sandbox-providers}/googlestorage/src/test/java/org/jclouds/googlestorage/blobstore/GoogleStorageContainerIntegrationLiveTest.java (100%) rename {providers => sandbox-providers}/googlestorage/src/test/java/org/jclouds/googlestorage/blobstore/GoogleStorageContainerLiveTest.java (100%) rename {providers => sandbox-providers}/googlestorage/src/test/java/org/jclouds/googlestorage/blobstore/GoogleStorageInputStreamMapIntegrationLiveTest.java (100%) rename {providers => sandbox-providers}/googlestorage/src/test/java/org/jclouds/googlestorage/blobstore/GoogleStorageServiceIntegrationLiveTest.java (100%) rename {providers => sandbox-providers}/googlestorage/src/test/java/org/jclouds/googlestorage/blobstore/GoogleStorageTestInitializer.java (100%) diff --git a/README.txt b/README.txt index 211789572a..ff09b7f225 100644 --- a/README.txt +++ b/README.txt @@ -43,7 +43,7 @@ our compute api supports: aws-ec2, gogrid, cloudservers-us, stub (in-memory), de our blobstore api supports: aws-s3, cloudfiles-us, cloudfiles-uk, filesystem, azureblob, atmos (generic), synaptic-storage, - cloudonestorage, walrus(generic), googlestorage, ninefold-storage, + cloudonestorage, walrus(generic), ninefold-storage, eucalyptus-partnercloud-s3, swift (generic), transient (in-mem) * note * the pom dependency org.jclouds/jclouds-allblobstore gives you access to @@ -55,7 +55,7 @@ our loadbalancer api supports: cloudloadbalancers-us to all of these providers we also have support for: ibmdev, mezeo, nirvanix, boxdotnet, openstack nova, scality ring, - hosteurope-storage, tiscali-storage, scaleup-storage, + hosteurope-storage, tiscali-storage, scaleup-storage, googlestorage, azurequeue, simpledb, cloudstack as well as a async-http-client driver in the sandbox diff --git a/allblobstore/pom.xml b/allblobstore/pom.xml index 4b562625d1..ac0bfbf517 100644 --- a/allblobstore/pom.xml +++ b/allblobstore/pom.xml @@ -39,11 +39,6 @@ aws-s3 ${project.version} - - org.jclouds.provider - googlestorage - ${project.version} - org.jclouds.provider ninefold-storage diff --git a/providers/pom.xml b/providers/pom.xml index 09340186e1..2529f07909 100644 --- a/providers/pom.xml +++ b/providers/pom.xml @@ -39,7 +39,6 @@ azureblob aws-s3 aws-ec2 - googlestorage synaptic-storage ninefold-storage cloudonestorage diff --git a/providers/googlestorage/README.txt b/sandbox-providers/googlestorage/README.txt similarity index 100% rename from providers/googlestorage/README.txt rename to sandbox-providers/googlestorage/README.txt diff --git a/providers/googlestorage/pom.xml b/sandbox-providers/googlestorage/pom.xml similarity index 100% rename from providers/googlestorage/pom.xml rename to sandbox-providers/googlestorage/pom.xml diff --git a/providers/googlestorage/src/main/java/org/jclouds/googlestorage/GoogleStorageAsyncClient.java b/sandbox-providers/googlestorage/src/main/java/org/jclouds/googlestorage/GoogleStorageAsyncClient.java similarity index 100% rename from providers/googlestorage/src/main/java/org/jclouds/googlestorage/GoogleStorageAsyncClient.java rename to sandbox-providers/googlestorage/src/main/java/org/jclouds/googlestorage/GoogleStorageAsyncClient.java diff --git a/providers/googlestorage/src/main/java/org/jclouds/googlestorage/GoogleStorageContextBuilder.java b/sandbox-providers/googlestorage/src/main/java/org/jclouds/googlestorage/GoogleStorageContextBuilder.java similarity index 100% rename from providers/googlestorage/src/main/java/org/jclouds/googlestorage/GoogleStorageContextBuilder.java rename to sandbox-providers/googlestorage/src/main/java/org/jclouds/googlestorage/GoogleStorageContextBuilder.java diff --git a/providers/googlestorage/src/main/java/org/jclouds/googlestorage/GoogleStoragePropertiesBuilder.java b/sandbox-providers/googlestorage/src/main/java/org/jclouds/googlestorage/GoogleStoragePropertiesBuilder.java similarity index 100% rename from providers/googlestorage/src/main/java/org/jclouds/googlestorage/GoogleStoragePropertiesBuilder.java rename to sandbox-providers/googlestorage/src/main/java/org/jclouds/googlestorage/GoogleStoragePropertiesBuilder.java diff --git a/providers/googlestorage/src/main/java/org/jclouds/googlestorage/GoogleStorageProviderMetadata.java b/sandbox-providers/googlestorage/src/main/java/org/jclouds/googlestorage/GoogleStorageProviderMetadata.java similarity index 100% rename from providers/googlestorage/src/main/java/org/jclouds/googlestorage/GoogleStorageProviderMetadata.java rename to sandbox-providers/googlestorage/src/main/java/org/jclouds/googlestorage/GoogleStorageProviderMetadata.java diff --git a/providers/googlestorage/src/main/java/org/jclouds/googlestorage/binders/BindGoogleStorageObjectMetadataToRequest.java b/sandbox-providers/googlestorage/src/main/java/org/jclouds/googlestorage/binders/BindGoogleStorageObjectMetadataToRequest.java similarity index 100% rename from providers/googlestorage/src/main/java/org/jclouds/googlestorage/binders/BindGoogleStorageObjectMetadataToRequest.java rename to sandbox-providers/googlestorage/src/main/java/org/jclouds/googlestorage/binders/BindGoogleStorageObjectMetadataToRequest.java diff --git a/providers/googlestorage/src/main/java/org/jclouds/googlestorage/config/GoogleStorageRestClientModule.java b/sandbox-providers/googlestorage/src/main/java/org/jclouds/googlestorage/config/GoogleStorageRestClientModule.java similarity index 100% rename from providers/googlestorage/src/main/java/org/jclouds/googlestorage/config/GoogleStorageRestClientModule.java rename to sandbox-providers/googlestorage/src/main/java/org/jclouds/googlestorage/config/GoogleStorageRestClientModule.java diff --git a/providers/googlestorage/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata b/sandbox-providers/googlestorage/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata similarity index 100% rename from providers/googlestorage/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata rename to sandbox-providers/googlestorage/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata diff --git a/providers/googlestorage/src/test/java/org/jclouds/googlestorage/GoogleStorageAsyncClientTestDisabled.java b/sandbox-providers/googlestorage/src/test/java/org/jclouds/googlestorage/GoogleStorageAsyncClientTestDisabled.java similarity index 100% rename from providers/googlestorage/src/test/java/org/jclouds/googlestorage/GoogleStorageAsyncClientTestDisabled.java rename to sandbox-providers/googlestorage/src/test/java/org/jclouds/googlestorage/GoogleStorageAsyncClientTestDisabled.java diff --git a/providers/googlestorage/src/test/java/org/jclouds/googlestorage/GoogleStorageClientLiveTest.java b/sandbox-providers/googlestorage/src/test/java/org/jclouds/googlestorage/GoogleStorageClientLiveTest.java similarity index 100% rename from providers/googlestorage/src/test/java/org/jclouds/googlestorage/GoogleStorageClientLiveTest.java rename to sandbox-providers/googlestorage/src/test/java/org/jclouds/googlestorage/GoogleStorageClientLiveTest.java diff --git a/providers/googlestorage/src/test/java/org/jclouds/googlestorage/GoogleStorageProviderTest.java b/sandbox-providers/googlestorage/src/test/java/org/jclouds/googlestorage/GoogleStorageProviderTest.java similarity index 100% rename from providers/googlestorage/src/test/java/org/jclouds/googlestorage/GoogleStorageProviderTest.java rename to sandbox-providers/googlestorage/src/test/java/org/jclouds/googlestorage/GoogleStorageProviderTest.java diff --git a/providers/googlestorage/src/test/java/org/jclouds/googlestorage/binders/BindGoogleStorageObjectMetadataToRequestTest.java b/sandbox-providers/googlestorage/src/test/java/org/jclouds/googlestorage/binders/BindGoogleStorageObjectMetadataToRequestTest.java similarity index 100% rename from providers/googlestorage/src/test/java/org/jclouds/googlestorage/binders/BindGoogleStorageObjectMetadataToRequestTest.java rename to sandbox-providers/googlestorage/src/test/java/org/jclouds/googlestorage/binders/BindGoogleStorageObjectMetadataToRequestTest.java diff --git a/providers/googlestorage/src/test/java/org/jclouds/googlestorage/blobstore/GoogleStorageBlobIntegrationLiveTest.java b/sandbox-providers/googlestorage/src/test/java/org/jclouds/googlestorage/blobstore/GoogleStorageBlobIntegrationLiveTest.java similarity index 100% rename from providers/googlestorage/src/test/java/org/jclouds/googlestorage/blobstore/GoogleStorageBlobIntegrationLiveTest.java rename to sandbox-providers/googlestorage/src/test/java/org/jclouds/googlestorage/blobstore/GoogleStorageBlobIntegrationLiveTest.java diff --git a/providers/googlestorage/src/test/java/org/jclouds/googlestorage/blobstore/GoogleStorageBlobLiveTest.java b/sandbox-providers/googlestorage/src/test/java/org/jclouds/googlestorage/blobstore/GoogleStorageBlobLiveTest.java similarity index 100% rename from providers/googlestorage/src/test/java/org/jclouds/googlestorage/blobstore/GoogleStorageBlobLiveTest.java rename to sandbox-providers/googlestorage/src/test/java/org/jclouds/googlestorage/blobstore/GoogleStorageBlobLiveTest.java diff --git a/providers/googlestorage/src/test/java/org/jclouds/googlestorage/blobstore/GoogleStorageBlobMapIntegrationLiveTest.java b/sandbox-providers/googlestorage/src/test/java/org/jclouds/googlestorage/blobstore/GoogleStorageBlobMapIntegrationLiveTest.java similarity index 100% rename from providers/googlestorage/src/test/java/org/jclouds/googlestorage/blobstore/GoogleStorageBlobMapIntegrationLiveTest.java rename to sandbox-providers/googlestorage/src/test/java/org/jclouds/googlestorage/blobstore/GoogleStorageBlobMapIntegrationLiveTest.java diff --git a/providers/googlestorage/src/test/java/org/jclouds/googlestorage/blobstore/GoogleStorageBlobSignerLiveTest.java b/sandbox-providers/googlestorage/src/test/java/org/jclouds/googlestorage/blobstore/GoogleStorageBlobSignerLiveTest.java similarity index 100% rename from providers/googlestorage/src/test/java/org/jclouds/googlestorage/blobstore/GoogleStorageBlobSignerLiveTest.java rename to sandbox-providers/googlestorage/src/test/java/org/jclouds/googlestorage/blobstore/GoogleStorageBlobSignerLiveTest.java diff --git a/providers/googlestorage/src/test/java/org/jclouds/googlestorage/blobstore/GoogleStorageContainerIntegrationLiveTest.java b/sandbox-providers/googlestorage/src/test/java/org/jclouds/googlestorage/blobstore/GoogleStorageContainerIntegrationLiveTest.java similarity index 100% rename from providers/googlestorage/src/test/java/org/jclouds/googlestorage/blobstore/GoogleStorageContainerIntegrationLiveTest.java rename to sandbox-providers/googlestorage/src/test/java/org/jclouds/googlestorage/blobstore/GoogleStorageContainerIntegrationLiveTest.java diff --git a/providers/googlestorage/src/test/java/org/jclouds/googlestorage/blobstore/GoogleStorageContainerLiveTest.java b/sandbox-providers/googlestorage/src/test/java/org/jclouds/googlestorage/blobstore/GoogleStorageContainerLiveTest.java similarity index 100% rename from providers/googlestorage/src/test/java/org/jclouds/googlestorage/blobstore/GoogleStorageContainerLiveTest.java rename to sandbox-providers/googlestorage/src/test/java/org/jclouds/googlestorage/blobstore/GoogleStorageContainerLiveTest.java diff --git a/providers/googlestorage/src/test/java/org/jclouds/googlestorage/blobstore/GoogleStorageInputStreamMapIntegrationLiveTest.java b/sandbox-providers/googlestorage/src/test/java/org/jclouds/googlestorage/blobstore/GoogleStorageInputStreamMapIntegrationLiveTest.java similarity index 100% rename from providers/googlestorage/src/test/java/org/jclouds/googlestorage/blobstore/GoogleStorageInputStreamMapIntegrationLiveTest.java rename to sandbox-providers/googlestorage/src/test/java/org/jclouds/googlestorage/blobstore/GoogleStorageInputStreamMapIntegrationLiveTest.java diff --git a/providers/googlestorage/src/test/java/org/jclouds/googlestorage/blobstore/GoogleStorageServiceIntegrationLiveTest.java b/sandbox-providers/googlestorage/src/test/java/org/jclouds/googlestorage/blobstore/GoogleStorageServiceIntegrationLiveTest.java similarity index 100% rename from providers/googlestorage/src/test/java/org/jclouds/googlestorage/blobstore/GoogleStorageServiceIntegrationLiveTest.java rename to sandbox-providers/googlestorage/src/test/java/org/jclouds/googlestorage/blobstore/GoogleStorageServiceIntegrationLiveTest.java diff --git a/providers/googlestorage/src/test/java/org/jclouds/googlestorage/blobstore/GoogleStorageTestInitializer.java b/sandbox-providers/googlestorage/src/test/java/org/jclouds/googlestorage/blobstore/GoogleStorageTestInitializer.java similarity index 100% rename from providers/googlestorage/src/test/java/org/jclouds/googlestorage/blobstore/GoogleStorageTestInitializer.java rename to sandbox-providers/googlestorage/src/test/java/org/jclouds/googlestorage/blobstore/GoogleStorageTestInitializer.java From 161906b98dd68fb12ac0d6a7410bc1e5f29a91f8 Mon Sep 17 00:00:00 2001 From: Adrian Cole Date: Thu, 2 Jun 2011 21:27:37 -0700 Subject: [PATCH 045/264] updated standard drives for skalicloud --- .../preinstalled_images.json | 47 ++++++++++++++++++- ...va => SkaliCloudMalaysiaProviderTest.java} | 4 +- ...iCloudMalaysiaTemplateBuilderLiveTest.java | 7 +-- 3 files changed, 52 insertions(+), 6 deletions(-) rename providers/skalicloud-sdg-my/src/test/java/org/jclouds/skalicloud/{SkaliCloudMalasyaProviderTest.java => SkaliCloudMalaysiaProviderTest.java} (90%) diff --git a/providers/skalicloud-sdg-my/src/main/resources/skalicloud-sdg-my/preinstalled_images.json b/providers/skalicloud-sdg-my/src/main/resources/skalicloud-sdg-my/preinstalled_images.json index 9e63077e83..c826fc32d3 100644 --- a/providers/skalicloud-sdg-my/src/main/resources/skalicloud-sdg-my/preinstalled_images.json +++ b/providers/skalicloud-sdg-my/src/main/resources/skalicloud-sdg-my/preinstalled_images.json @@ -14,6 +14,21 @@ "osVersion": "5.5", "size": "1" }, + { + "uuid": "0a4ef5e8-83d2-4b61-8fbe-0ff0232265f5", + "description": "CentOS 5.6 -32bit", + "osFamily": "CENTOS", + "osVersion": "5.6", + "is64bit": false, + "size": "1" + }, + { + "uuid": "66bc99a9-dfd4-4624-948a-57784e2cc411", + "description": "CentOS 5.6 -64bit", + "osFamily": "CENTOS", + "osVersion": "5.6", + "size": "1" + }, { "uuid": "c144d7a7-e24b-48ab-954b-6b6ec514ed6f", "description": "Debian 5 -64bit", @@ -21,6 +36,36 @@ "osVersion": "5.0", "size": "1" }, + { + "uuid": "0178c66a-fc5b-43c6-bec5-3315fef924d2", + "description": "Debian 5 -32bit", + "osFamily": "DEBIAN", + "osVersion": "5.0", + "is64bit": false, + "size": "1" + }, + { + "uuid": "88cd1475-b6a0-4121-b9c2-97ddd652b410", + "description": "Debian 6 -64bit -Experimental", + "osFamily": "DEBIAN", + "osVersion": "6.0", + "size": "1" + }, + { + "uuid": "53e4b089-d35d-4aca-a95e-ff72774d3750", + "description": "Ubuntu Server 10.04 -64bit", + "osFamily": "UBUNTU", + "osVersion": "10.04", + "size": "1" + }, + { + "uuid": "877ea99b-7d42-4be7-9cf6-88b8daad9a8c", + "description": "Ubuntu Server 10.04 -32bit", + "osFamily": "UBUNTU", + "osVersion": "10.04", + "is64bit": false, + "size": "1" + }, { "uuid": "3051699a-a536-4220-aeb5-67f2ec101a09", "description": "Ubuntu Server 10.10 -64bit", @@ -28,7 +73,7 @@ "osVersion": "10.10", "size": "1" }, - { + { "uuid": "4d5656b5-74d3-4aa0-9308-6b7377552204", "description": "Ubuntu Server 10.10 -32bit", "osFamily": "UBUNTU", diff --git a/providers/skalicloud-sdg-my/src/test/java/org/jclouds/skalicloud/SkaliCloudMalasyaProviderTest.java b/providers/skalicloud-sdg-my/src/test/java/org/jclouds/skalicloud/SkaliCloudMalaysiaProviderTest.java similarity index 90% rename from providers/skalicloud-sdg-my/src/test/java/org/jclouds/skalicloud/SkaliCloudMalasyaProviderTest.java rename to providers/skalicloud-sdg-my/src/test/java/org/jclouds/skalicloud/SkaliCloudMalaysiaProviderTest.java index fb703e4d03..2676b28809 100644 --- a/providers/skalicloud-sdg-my/src/test/java/org/jclouds/skalicloud/SkaliCloudMalasyaProviderTest.java +++ b/providers/skalicloud-sdg-my/src/test/java/org/jclouds/skalicloud/SkaliCloudMalaysiaProviderTest.java @@ -27,9 +27,9 @@ import org.testng.annotations.Test; * @author Adrian Cole */ @Test(groups = "unit", testName = "SkaliCloudMalaysiaProviderTest") -public class SkaliCloudMalasyaProviderTest extends BaseProviderMetadataTest { +public class SkaliCloudMalaysiaProviderTest extends BaseProviderMetadataTest { - public SkaliCloudMalasyaProviderTest() { + public SkaliCloudMalaysiaProviderTest() { super(new SkaliCloudMalaysiaProviderMetadata(), ProviderMetadata.COMPUTE_TYPE); } } diff --git a/providers/skalicloud-sdg-my/src/test/java/org/jclouds/skalicloud/compute/SkaliCloudMalaysiaTemplateBuilderLiveTest.java b/providers/skalicloud-sdg-my/src/test/java/org/jclouds/skalicloud/compute/SkaliCloudMalaysiaTemplateBuilderLiveTest.java index ebc3a9e155..260866c28c 100644 --- a/providers/skalicloud-sdg-my/src/test/java/org/jclouds/skalicloud/compute/SkaliCloudMalaysiaTemplateBuilderLiveTest.java +++ b/providers/skalicloud-sdg-my/src/test/java/org/jclouds/skalicloud/compute/SkaliCloudMalaysiaTemplateBuilderLiveTest.java @@ -53,11 +53,12 @@ public class SkaliCloudMalaysiaTemplateBuilderLiveTest extends BaseTemplateBuild public boolean apply(OsFamilyVersion64Bit input) { switch (input.family) { case UBUNTU: - return input.version.equals("") || input.version.equals("10.10"); + return input.version.equals("") || input.version.matches("10.[01][04]"); case DEBIAN: - return (input.version.equals("") || input.version.equals("5.0")) && input.is64Bit; + return (input.version.equals("") || input.version.equals("5.0")) + || (input.version.equals("6.0") && input.is64Bit); case CENTOS: - return input.version.equals("") || input.version.equals("5.5"); + return input.version.equals("") || input.version.matches("5.[56]"); case WINDOWS: return (input.version.equals("") || input.version.equals("2008 R2")) && input.is64Bit; default: From c8bbe64403b41e10b16e885c1282c3861ddcb844 Mon Sep 17 00:00:00 2001 From: Kedar Dave Date: Fri, 3 Jun 2011 00:16:36 -0500 Subject: [PATCH 046/264] cleanup and refine vmclientlivetest --- .../vpdc/features/VMClientLiveTest.java | 38 +++++-------------- 1 file changed, 10 insertions(+), 28 deletions(-) diff --git a/providers/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/features/VMClientLiveTest.java b/providers/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/features/VMClientLiveTest.java index db58130890..33a06932b0 100644 --- a/providers/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/features/VMClientLiveTest.java +++ b/providers/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/features/VMClientLiveTest.java @@ -21,11 +21,9 @@ package org.jclouds.savvis.vpdc.features; import static com.google.common.base.Preconditions.checkNotNull; import static org.testng.Assert.assertEquals; -import java.util.Properties; import java.util.Set; import java.util.concurrent.TimeUnit; -import org.jclouds.Constants; import org.jclouds.cim.OSType; import org.jclouds.compute.domain.CIMOperatingSystem; import org.jclouds.compute.domain.ExecResponse; @@ -194,8 +192,8 @@ public class VMClientLiveTest extends BaseVPDCClientLiveTest { // fetch the task again, in savvis, task.getOwner is populated with vApp after task has finished task = restContext.getApi().getBrowsingClient().getTask(task.getId()); - vm = restContext.getApi().getBrowsingClient().getVM(task.getOwner().getHref(), GetVMOptions.NONE); - assert vm.getHref() != null : vm; + VM newVM = restContext.getApi().getBrowsingClient().getVM(task.getOwner().getHref(), GetVMOptions.NONE); + assert newVM.getHref() != null : newVM; } } @@ -242,7 +240,7 @@ public class VMClientLiveTest extends BaseVPDCClientLiveTest { } } - @Test(dependsOnMethods="testPowerOnVM") + @Test(dependsOnMethods="testCreateVirtualMachine") public void testCloneVApp() throws Exception { billingSiteId = restContext.getApi().getBrowsingClient().getOrg(null).getId();// default vpdcId = Iterables.find(restContext.getApi().getBrowsingClient().getOrg(billingSiteId).getVDCs(), @@ -264,7 +262,11 @@ public class VMClientLiveTest extends BaseVPDCClientLiveTest { restContext.getApi().getBrowsingClient().getVDCInOrg(billingSiteId, vpdcId).getAvailableNetworks(), 0) .getId(); - Task task = client.cloneVApp(vm.getHref(), "clonedvm", networkTierName); + String clonedVMName = vm.getName() + "clone"; + + System.out.printf("Cloning vm - name %s in vpdcId %s in network %s, newVM name is %s%n", vm.getName(), vpdcId, networkTierName, clonedVMName); + + Task task = client.cloneVApp(vm.getHref(), clonedVMName, networkTierName); // make sure there's no error assert task.getId() != null && task.getError() == null : task; @@ -273,8 +275,8 @@ public class VMClientLiveTest extends BaseVPDCClientLiveTest { // fetch the task again, in savvis, task.getOwner is populated with vApp after task has finished task = restContext.getApi().getBrowsingClient().getTask(task.getId()); - vm = restContext.getApi().getBrowsingClient().getVM(task.getOwner().getHref(), GetVMOptions.NONE); - assert vm.getHref() != null : vm; + VM clonedVM = restContext.getApi().getBrowsingClient().getVM(task.getOwner().getHref(), GetVMOptions.NONE); + assert clonedVM.getHref() != null : clonedVM; } private void conditionallyCheckSSH() { @@ -304,26 +306,6 @@ public class VMClientLiveTest extends BaseVPDCClientLiveTest { } } - @Test(dependsOnMethods="testCreateVirtualMachine") - public void testPowerOffVM() throws Exception { - Task task = client.powerOffVM(vm.getHref()); - - // make sure there's no error - assert task.getId() != null && task.getError() == null : task; - - assert this.taskTester.apply(task.getId()); - } - - @Test(dependsOnMethods="testPowerOffVM") - public void testPowerOnVM() throws Exception { - Task task = client.powerOnVM(vm.getHref()); - - // make sure there's no error - assert task.getId() != null && task.getError() == null : task; - - assert this.taskTester.apply(task.getId()); - } - @AfterGroups(groups = "live") protected void tearDown() { if (vm != null) { From 17db25cceb2b83b57588dec05fc62162822b6d4f Mon Sep 17 00:00:00 2001 From: Jeremy Whitlock Date: Thu, 2 Jun 2011 23:58:50 -0600 Subject: [PATCH 047/264] Issue 550: Added ProviderMetadata for AT&T Synaptic Storage. [in providers/synaptic-storage/src] * main/java/org/jclouds/synaptic/storage/SynapticStorageProviderMetadata.java, src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata, src/test/java/org/jclouds/synaptic/storage/SynapticStorageProviderTest.java: Added. --- .../SynapticStorageProviderMetadata.java | 109 ++++++++++++++++++ .../org.jclouds.providers.ProviderMetadata | 1 + .../storage/SynapticStorageProviderTest.java | 37 ++++++ 3 files changed, 147 insertions(+) create mode 100644 providers/synaptic-storage/src/main/java/org/jclouds/synaptic/storage/SynapticStorageProviderMetadata.java create mode 100644 providers/synaptic-storage/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata create mode 100644 providers/synaptic-storage/src/test/java/org/jclouds/synaptic/storage/SynapticStorageProviderTest.java diff --git a/providers/synaptic-storage/src/main/java/org/jclouds/synaptic/storage/SynapticStorageProviderMetadata.java b/providers/synaptic-storage/src/main/java/org/jclouds/synaptic/storage/SynapticStorageProviderMetadata.java new file mode 100644 index 0000000000..a5b8c84edc --- /dev/null +++ b/providers/synaptic-storage/src/main/java/org/jclouds/synaptic/storage/SynapticStorageProviderMetadata.java @@ -0,0 +1,109 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.jclouds.synaptic.storage; + +import com.google.common.collect.ImmutableSet; + +import java.net.URI; +import java.util.Set; + +import org.jclouds.providers.BaseProviderMetadata; +import org.jclouds.providers.ProviderMetadata; + +/** + * Implementation of {@link org.jclouds.types.ProviderMetadata} for AT&T's + * Synaptic Storage provider. + * + * @author Jeremy Whitlock + */ +public class SynapticStorageProviderMetadata extends BaseProviderMetadata { + + /** + * {@inheritDoc} + */ + @Override + public String getId() { + return "synaptic-storage"; + } + + /** + * {@inheritDoc} + */ + @Override + public String getType() { + return ProviderMetadata.BLOBSTORE_TYPE; + } + + /** + * {@inheritDoc} + */ + @Override + public String getName() { + return "AT&T Synaptic Storage"; + } + + /** + * {@inheritDoc} + */ + @Override + public String getIdentityName() { + return "Email Username"; + } + + /** + * {@inheritDoc} + */ + @Override + public String getCredentialName() { + return "Password"; + } + + /** + * {@inheritDoc} + */ + @Override + public URI getHomepage() { + return URI.create("https://www.synaptic.att.com/"); + } + + /** + * {@inheritDoc} + */ + @Override + public URI getConsole() { + return URI.create("https://www.synaptic.att.com/clouduser/login.htm"); + } + + /** + * {@inheritDoc} + */ + @Override + public URI getApiDocumentation() { + return URI.create("https://www.synaptic.att.com/clouduser/emc_atmos_api.htm"); + } + + /** + * {@inheritDoc} + */ + @Override + public Set getIso3166Codes() { + return ImmutableSet.of("US-VA", "US-TX"); + } + +} \ No newline at end of file diff --git a/providers/synaptic-storage/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata b/providers/synaptic-storage/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata new file mode 100644 index 0000000000..35deaa8fcb --- /dev/null +++ b/providers/synaptic-storage/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata @@ -0,0 +1 @@ +org.jclouds.synaptic.storage.SynapticStorageProviderMetadata diff --git a/providers/synaptic-storage/src/test/java/org/jclouds/synaptic/storage/SynapticStorageProviderTest.java b/providers/synaptic-storage/src/test/java/org/jclouds/synaptic/storage/SynapticStorageProviderTest.java new file mode 100644 index 0000000000..92e7aab916 --- /dev/null +++ b/providers/synaptic-storage/src/test/java/org/jclouds/synaptic/storage/SynapticStorageProviderTest.java @@ -0,0 +1,37 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.jclouds.synaptic.storage; + +import org.jclouds.providers.BaseProviderMetadataTest; +import org.jclouds.providers.ProviderMetadata; +import org.testng.annotations.Test; + +/** + * The SynapticStorageProviderTest tests the {@link org.jclouds.synaptic.storage.SynapticStorageProviderMetadata} class. + * + * @author Jeremy Whitlock + */ +@Test(groups = "unit", testName = "SynapticStorageProviderTest") +public class SynapticStorageProviderTest extends BaseProviderMetadataTest { + + public SynapticStorageProviderTest() { + super(new SynapticStorageProviderMetadata(), ProviderMetadata.BLOBSTORE_TYPE); + } + +} \ No newline at end of file From 63cd9d0535ef40c8997d0142c110a99f2e73a498 Mon Sep 17 00:00:00 2001 From: Jeremy Whitlock Date: Fri, 3 Jun 2011 00:06:38 -0600 Subject: [PATCH 048/264] Issue 550: Cleaned up a few minor formatting nits and implemented linked services for Eucalyptus. [in providers] * aws-s3/src/main/java/org/jclouds/aws/s3/AWSS3ProviderMetadata.java: Fixed a javadoc link. * aws-s3/src/test/java/org/jclouds/aws/s3/AWSS3ProviderTest.java: Fixed a javadoc link and fixed an erroneous full-qualified class reference. * eucalyptus-partnercloud-ec2/src/main/java/org/jclouds/epc/EucalyptusPartnerCloudEC2ProviderMetadata.java, eucalyptus-partnercloud-s3/src/main/java/org/jclouds/epc/EucalyptusPartnerCloudS3ProviderMetadata.java (getLinkedServices): Implemented. --- .../java/org/jclouds/aws/s3/AWSS3ProviderMetadata.java | 2 +- .../test/java/org/jclouds/aws/s3/AWSS3ProviderTest.java | 3 ++- .../epc/EucalyptusPartnerCloudEC2ProviderMetadata.java | 8 ++++++++ .../epc/EucalyptusPartnerCloudS3ProviderMetadata.java | 8 ++++++++ 4 files changed, 19 insertions(+), 2 deletions(-) diff --git a/providers/aws-s3/src/main/java/org/jclouds/aws/s3/AWSS3ProviderMetadata.java b/providers/aws-s3/src/main/java/org/jclouds/aws/s3/AWSS3ProviderMetadata.java index a62c0e7aa5..975b258dc9 100644 --- a/providers/aws-s3/src/main/java/org/jclouds/aws/s3/AWSS3ProviderMetadata.java +++ b/providers/aws-s3/src/main/java/org/jclouds/aws/s3/AWSS3ProviderMetadata.java @@ -27,7 +27,7 @@ import org.jclouds.providers.BaseProviderMetadata; import org.jclouds.providers.ProviderMetadata; /** - * Implementation of @ link org.jclouds.types.ProviderMetadata} for Amazon's Simple Storage Service + * Implementation of {@link org.jclouds.types.ProviderMetadata} for Amazon's Simple Storage Service * (S3) provider. * * @author Adrian Cole diff --git a/providers/aws-s3/src/test/java/org/jclouds/aws/s3/AWSS3ProviderTest.java b/providers/aws-s3/src/test/java/org/jclouds/aws/s3/AWSS3ProviderTest.java index 397c4ba7bf..cf959d187c 100644 --- a/providers/aws-s3/src/test/java/org/jclouds/aws/s3/AWSS3ProviderTest.java +++ b/providers/aws-s3/src/test/java/org/jclouds/aws/s3/AWSS3ProviderTest.java @@ -23,7 +23,7 @@ import org.jclouds.providers.ProviderMetadata; import org.testng.annotations.Test; /** - * The AWSS3ProviderTest tests the org.jclouds.providers.AWSS3Provider class. + * The AWSS3ProviderTest tests the {@link org.jclouds.aws.s3.AWSS3ProviderMetadata} class. * * @author Adrian Cole */ @@ -33,4 +33,5 @@ public class AWSS3ProviderTest extends BaseProviderMetadataTest { public AWSS3ProviderTest() { super(new AWSS3ProviderMetadata(), ProviderMetadata.BLOBSTORE_TYPE); } + } \ No newline at end of file diff --git a/providers/eucalyptus-partnercloud-ec2/src/main/java/org/jclouds/epc/EucalyptusPartnerCloudEC2ProviderMetadata.java b/providers/eucalyptus-partnercloud-ec2/src/main/java/org/jclouds/epc/EucalyptusPartnerCloudEC2ProviderMetadata.java index c18ed12397..4158bdbac9 100644 --- a/providers/eucalyptus-partnercloud-ec2/src/main/java/org/jclouds/epc/EucalyptusPartnerCloudEC2ProviderMetadata.java +++ b/providers/eucalyptus-partnercloud-ec2/src/main/java/org/jclouds/epc/EucalyptusPartnerCloudEC2ProviderMetadata.java @@ -97,6 +97,14 @@ public class EucalyptusPartnerCloudEC2ProviderMetadata extends BaseProviderMetad return URI.create("http://open.eucalyptus.com/wiki/IntroducingEucalyptus_v2.0"); } + /** + * {@inheritDoc} + */ + @Override + public Set getLinkedServices() { + return ImmutableSet.of("eucalyptus-partnercloud-ec2", "eucalyptus-partnercloud-s3"); + } + /** * {@inheritDoc} */ diff --git a/providers/eucalyptus-partnercloud-s3/src/main/java/org/jclouds/epc/EucalyptusPartnerCloudS3ProviderMetadata.java b/providers/eucalyptus-partnercloud-s3/src/main/java/org/jclouds/epc/EucalyptusPartnerCloudS3ProviderMetadata.java index 0c1d6d2d38..38b97d7af1 100644 --- a/providers/eucalyptus-partnercloud-s3/src/main/java/org/jclouds/epc/EucalyptusPartnerCloudS3ProviderMetadata.java +++ b/providers/eucalyptus-partnercloud-s3/src/main/java/org/jclouds/epc/EucalyptusPartnerCloudS3ProviderMetadata.java @@ -97,6 +97,14 @@ public class EucalyptusPartnerCloudS3ProviderMetadata extends BaseProviderMetada return URI.create("http://open.eucalyptus.com/wiki/IntroducingEucalyptus_v2.0"); } + /** + * {@inheritDoc} + */ + @Override + public Set getLinkedServices() { + return ImmutableSet.of("eucalyptus-partnercloud-ec2", "eucalyptus-partnercloud-s3"); + } + /** * {@inheritDoc} */ From 691e69a961dccbd6e1a252f4505bfbc07bdeaa55 Mon Sep 17 00:00:00 2001 From: Jeremy Whitlock Date: Fri, 3 Jun 2011 00:11:14 -0600 Subject: [PATCH 049/264] Issue 550: Addressed the verbiage used for credentials for the synaptic-storage provider. [in providers/synaptic-storage/src] * main/java/org/jclouds/synaptic/storage/SynapticStorageProviderMetadata.java (getIdentityName, getCredentialName): Updated to use ATMOS verbiage per Adrian's feedback. --- .../synaptic/storage/SynapticStorageProviderMetadata.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/providers/synaptic-storage/src/main/java/org/jclouds/synaptic/storage/SynapticStorageProviderMetadata.java b/providers/synaptic-storage/src/main/java/org/jclouds/synaptic/storage/SynapticStorageProviderMetadata.java index a5b8c84edc..ad5196a1b8 100644 --- a/providers/synaptic-storage/src/main/java/org/jclouds/synaptic/storage/SynapticStorageProviderMetadata.java +++ b/providers/synaptic-storage/src/main/java/org/jclouds/synaptic/storage/SynapticStorageProviderMetadata.java @@ -63,7 +63,7 @@ public class SynapticStorageProviderMetadata extends BaseProviderMetadata { */ @Override public String getIdentityName() { - return "Email Username"; + return "Subtenant ID"; } /** @@ -71,7 +71,7 @@ public class SynapticStorageProviderMetadata extends BaseProviderMetadata { */ @Override public String getCredentialName() { - return "Password"; + return "Shared Secret"; } /** From e0bb0bc4d735a942bdd35151d73416258680852c Mon Sep 17 00:00:00 2001 From: Jeremy Whitlock Date: Fri, 3 Jun 2011 00:33:37 -0600 Subject: [PATCH 050/264] Issue 550: Added ProviderMetadata for OpenHosting East1 provider. [in jclouds/openhosting-east1/src] * main/java/org/jclouds/openhosting/OpenHostingEast1ProviderMetadata.java, main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata, test/java/org/jclouds/openhosting/OpenHostingEast1ProviderTest.java: Added. --- .../OpenHostingEast1ProviderMetadata.java | 108 ++++++++++++++++++ .../org.jclouds.providers.ProviderMetadata | 1 + .../OpenHostingEast1ProviderTest.java | 37 ++++++ 3 files changed, 146 insertions(+) create mode 100644 providers/openhosting-east1/src/main/java/org/jclouds/openhosting/OpenHostingEast1ProviderMetadata.java create mode 100644 providers/openhosting-east1/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata create mode 100644 providers/openhosting-east1/src/test/java/org/jclouds/openhosting/OpenHostingEast1ProviderTest.java diff --git a/providers/openhosting-east1/src/main/java/org/jclouds/openhosting/OpenHostingEast1ProviderMetadata.java b/providers/openhosting-east1/src/main/java/org/jclouds/openhosting/OpenHostingEast1ProviderMetadata.java new file mode 100644 index 0000000000..e5df64b112 --- /dev/null +++ b/providers/openhosting-east1/src/main/java/org/jclouds/openhosting/OpenHostingEast1ProviderMetadata.java @@ -0,0 +1,108 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.jclouds.openhosting; + +import com.google.common.collect.ImmutableSet; + +import java.net.URI; +import java.util.Set; + +import org.jclouds.providers.BaseProviderMetadata; + +/** + * Implementation of {@link org.jclouds.types.ProviderMetadata} for OpenHosting's + * East1 provider. + * + * @author Jeremy Whitlock + */ +public class OpenHostingEast1ProviderMetadata extends BaseProviderMetadata { + + /** + * {@inheritDoc} + */ + @Override + public String getId() { + return "openhosting-east1"; + } + + /** + * {@inheritDoc} + */ + @Override + public String getType() { + return COMPUTE_TYPE; + } + + /** + * {@inheritDoc} + */ + @Override + public String getName() { + return "OpenHosting East1"; + } + + /** + * {@inheritDoc} + */ + @Override + public String getIdentityName() { + return "User UUID"; + } + + /** + * {@inheritDoc} + */ + @Override + public String getCredentialName() { + return "Secret API Key"; + } + + /** + * {@inheritDoc} + */ + @Override + public URI getHomepage() { + return URI.create("https://east1.openhosting.com/"); + } + + /** + * {@inheritDoc} + */ + @Override + public URI getConsole() { + return URI.create("https://east1.openhosting.com/accounts/login"); + } + + /** + * {@inheritDoc} + */ + @Override + public URI getApiDocumentation() { + return URI.create("http://www.openhosting.com/support/api/"); + } + + /** + * {@inheritDoc} + */ + @Override + public Set getIso3166Codes() { + return ImmutableSet.of("US-VA"); + } + +} diff --git a/providers/openhosting-east1/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata b/providers/openhosting-east1/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata new file mode 100644 index 0000000000..996483c31e --- /dev/null +++ b/providers/openhosting-east1/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata @@ -0,0 +1 @@ +org.jclouds.openhosting.OpenHostingEast1ProviderMetadata diff --git a/providers/openhosting-east1/src/test/java/org/jclouds/openhosting/OpenHostingEast1ProviderTest.java b/providers/openhosting-east1/src/test/java/org/jclouds/openhosting/OpenHostingEast1ProviderTest.java new file mode 100644 index 0000000000..3910128e9c --- /dev/null +++ b/providers/openhosting-east1/src/test/java/org/jclouds/openhosting/OpenHostingEast1ProviderTest.java @@ -0,0 +1,37 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.jclouds.openhosting; + +import org.jclouds.providers.BaseProviderMetadataTest; +import org.jclouds.providers.ProviderMetadata; +import org.testng.annotations.Test; + +/** + * The OpenHostingEast1ProviderTest tests the {@link OpenHostingEast1ProviderMetadata} class. + * + * @author Jeremy Whitlock + */ +@Test(groups = "unit", testName = "OpenHostingEast1ProviderTest") +public class OpenHostingEast1ProviderTest extends BaseProviderMetadataTest { + + public OpenHostingEast1ProviderTest() { + super(new OpenHostingEast1ProviderMetadata(), ProviderMetadata.COMPUTE_TYPE); + } + +} \ No newline at end of file From 1340e38728db3a34cb94d9b6892b0398c395157c Mon Sep 17 00:00:00 2001 From: Jeremy Whitlock Date: Fri, 3 Jun 2011 00:48:20 -0600 Subject: [PATCH 051/264] Issue 550: Added ProviderMetadata for Ninefold Storage. [in providers/ninefold-storage/src] * main/java/org/jclouds/ninefold/storage/NinefoldStorageProviderMetadata.java, main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata, test/java/org/jclouds/ninefold/storage/NinefoldStorageProviderTest.java: Added. --- .../NinefoldStorageProviderMetadata.java | 108 ++++++++++++++++++ .../org.jclouds.providers.ProviderMetadata | 1 + .../storage/NinefoldStorageProviderTest.java | 37 ++++++ 3 files changed, 146 insertions(+) create mode 100644 providers/ninefold-storage/src/main/java/org/jclouds/ninefold/storage/NinefoldStorageProviderMetadata.java create mode 100644 providers/ninefold-storage/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata create mode 100644 providers/ninefold-storage/src/test/java/org/jclouds/ninefold/storage/NinefoldStorageProviderTest.java diff --git a/providers/ninefold-storage/src/main/java/org/jclouds/ninefold/storage/NinefoldStorageProviderMetadata.java b/providers/ninefold-storage/src/main/java/org/jclouds/ninefold/storage/NinefoldStorageProviderMetadata.java new file mode 100644 index 0000000000..b165afa4c0 --- /dev/null +++ b/providers/ninefold-storage/src/main/java/org/jclouds/ninefold/storage/NinefoldStorageProviderMetadata.java @@ -0,0 +1,108 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.jclouds.ninefold.storage; + +import com.google.common.collect.ImmutableSet; + +import java.net.URI; +import java.util.Set; + +import org.jclouds.providers.BaseProviderMetadata; + +/** + * Implementation of {@link org.jclouds.types.ProviderMetadata} for Ninefold's + * Storage provider. + * + * @author Jeremy Whitlock + */ +public class NinefoldStorageProviderMetadata extends BaseProviderMetadata { + + /** + * {@inheritDoc} + */ + @Override + public String getId() { + return "ninefold-storage"; + } + + /** + * {@inheritDoc} + */ + @Override + public String getType() { + return BLOBSTORE_TYPE; + } + + /** + * {@inheritDoc} + */ + @Override + public String getName() { + return "Ninefold Storage"; + } + + /** + * {@inheritDoc} + */ + @Override + public String getIdentityName() { + return "Subtenant ID (UID)"; + } + + /** + * {@inheritDoc} + */ + @Override + public String getCredentialName() { + return "Shared Secret"; + } + + /** + * {@inheritDoc} + */ + @Override + public URI getHomepage() { + return URI.create("http://ninefold.com/cloud-storage/"); + } + + /** + * {@inheritDoc} + */ + @Override + public URI getConsole() { + return URI.create("https://ninefold.com/portal/"); + } + + /** + * {@inheritDoc} + */ + @Override + public URI getApiDocumentation() { + return URI.create("https://ninefold.com/support/display/SPT/API+Documentation"); + } + + /** + * {@inheritDoc} + */ + @Override + public Set getIso3166Codes() { + return ImmutableSet.of("AU-NSW"); + } + +} diff --git a/providers/ninefold-storage/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata b/providers/ninefold-storage/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata new file mode 100644 index 0000000000..f87f414387 --- /dev/null +++ b/providers/ninefold-storage/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata @@ -0,0 +1 @@ +org.jclouds.ninefold.storage.NinefoldStorageProviderMetadata diff --git a/providers/ninefold-storage/src/test/java/org/jclouds/ninefold/storage/NinefoldStorageProviderTest.java b/providers/ninefold-storage/src/test/java/org/jclouds/ninefold/storage/NinefoldStorageProviderTest.java new file mode 100644 index 0000000000..e087c0ef19 --- /dev/null +++ b/providers/ninefold-storage/src/test/java/org/jclouds/ninefold/storage/NinefoldStorageProviderTest.java @@ -0,0 +1,37 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.jclouds.ninefold.storage; + +import org.jclouds.providers.BaseProviderMetadataTest; +import org.jclouds.providers.ProviderMetadata; +import org.testng.annotations.Test; + +/** + * The NinefoldStorageProviderTest tests the {@link NinefoldStorageProviderMetadata} class. + * + * @author Jeremy Whitlock + */ +@Test(groups = "unit", testName = "NinefoldStorageProviderTest") +public class NinefoldStorageProviderTest extends BaseProviderMetadataTest { + + public NinefoldStorageProviderTest() { + super(new NinefoldStorageProviderMetadata(), ProviderMetadata.BLOBSTORE_TYPE); + } + +} \ No newline at end of file From 770023a8920d42b4c21fcab778fde1e34f1af4a2 Mon Sep 17 00:00:00 2001 From: Jeremy Whitlock Date: Fri, 3 Jun 2011 00:50:28 -0600 Subject: [PATCH 052/264] Issue 550: Global ATMOS refactoring for identity. [in providers] * cloudonestorage/src/main/java/org/jclouds/cloudonestorage/CloudOneStorageProviderMetadata.java, synaptic-storage/src/main/java/org/jclouds/synaptic/storage/SynapticStorageProviderMetadata.java (getIdentityName): Changed "Subtenant ID" to "Subtenant ID (UID)". --- .../cloudonestorage/CloudOneStorageProviderMetadata.java | 2 +- .../synaptic/storage/SynapticStorageProviderMetadata.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/providers/cloudonestorage/src/main/java/org/jclouds/cloudonestorage/CloudOneStorageProviderMetadata.java b/providers/cloudonestorage/src/main/java/org/jclouds/cloudonestorage/CloudOneStorageProviderMetadata.java index 5c0300b989..6f0c3102f5 100644 --- a/providers/cloudonestorage/src/main/java/org/jclouds/cloudonestorage/CloudOneStorageProviderMetadata.java +++ b/providers/cloudonestorage/src/main/java/org/jclouds/cloudonestorage/CloudOneStorageProviderMetadata.java @@ -62,7 +62,7 @@ public class CloudOneStorageProviderMetadata extends BaseProviderMetadata { */ @Override public String getIdentityName() { - return "Subtenant ID"; + return "Subtenant ID (UID)"; } /** diff --git a/providers/synaptic-storage/src/main/java/org/jclouds/synaptic/storage/SynapticStorageProviderMetadata.java b/providers/synaptic-storage/src/main/java/org/jclouds/synaptic/storage/SynapticStorageProviderMetadata.java index ad5196a1b8..1865fb4d9b 100644 --- a/providers/synaptic-storage/src/main/java/org/jclouds/synaptic/storage/SynapticStorageProviderMetadata.java +++ b/providers/synaptic-storage/src/main/java/org/jclouds/synaptic/storage/SynapticStorageProviderMetadata.java @@ -63,7 +63,7 @@ public class SynapticStorageProviderMetadata extends BaseProviderMetadata { */ @Override public String getIdentityName() { - return "Subtenant ID"; + return "Subtenant ID (UID)"; } /** From 69aac6b455a1a50037081e0dda1018d84a5304f1 Mon Sep 17 00:00:00 2001 From: Mattias Holmqvist Date: Fri, 3 Jun 2011 09:29:04 +0200 Subject: [PATCH 053/264] Cleaning up API for ebs2 and elastic-ip2 after review. Minor changes to doc-strings, code formatting and order of args in release fn. --- .../src/main/clojure/org/jclouds/ec2/ebs2.clj | 37 +++++++++---------- .../clojure/org/jclouds/ec2/elastic_ip2.clj | 13 +++---- 2 files changed, 24 insertions(+), 26 deletions(-) diff --git a/apis/ec2/src/main/clojure/org/jclouds/ec2/ebs2.clj b/apis/ec2/src/main/clojure/org/jclouds/ec2/ebs2.clj index ed7be97a54..1252090ddd 100644 --- a/apis/ec2/src/main/clojure/org/jclouds/ec2/ebs2.clj +++ b/apis/ec2/src/main/clojure/org/jclouds/ec2/ebs2.clj @@ -37,7 +37,7 @@ [v] (instance? Volume v)) -(defn #^org.jclouds.ec2.services.ElasticBlockStoreClient +(defn ^org.jclouds.ec2.services.ElasticBlockStoreClient ebs-service "" [compute] @@ -68,7 +68,7 @@ "Returns a string volume ID taken from the given string, keyword, or Volume argument." [v] (cond - (instance? Volume v) (.getId #^Volume v) + (instance? Volume v) (.getId ^Volume v) (keyword? v) (name v) (string? v) v :else (throw (IllegalArgumentException. @@ -77,7 +77,6 @@ (defn volumes "Returns a set of org.jclouds.ec2.domain.Volume instances corresponding to the volumes in the specified region (defaulting to your account's default region)." - [compute & [region & volume-ids]] (set (.describeVolumesInRegion (ebs-service compute) @@ -86,6 +85,7 @@ (if (get-region region) volume-ids (when region (cons region volume-ids)))))))) + (defn- as-string [v] (cond @@ -95,6 +95,7 @@ (defn- get-string [map key] (as-string (get map key))) + (defn- as-int [v] (cond @@ -138,9 +139,8 @@ "Creates a snapshot of a volume in the specified region with an optional description. If provided, the description must be < 255 characters in length. Returns the org.jclouds.aws.ec2.domain.Snapshot object representing the created snapshot." - - ([compute #^Volume volume] (create-snapshot compute volume nil)) - ([compute #^Volume volume description] (create-snapshot compute (.getRegion volume) (.getId volume) description)) + ([compute ^Volume volume] (create-snapshot compute volume nil)) + ([compute ^Volume volume description] (create-snapshot compute (.getRegion volume) (.getId volume) description)) ([compute region volume-id description] (.createSnapshotInRegion (ebs-service compute) (get-region region) @@ -150,7 +150,7 @@ (defn delete-snapshot "Deletes a snapshot in the specified region." - ([compute #^Snapshot snapshot] (delete-snapshot compute (.getRegion snapshot) (.getId snapshot))) + ([compute ^Snapshot snapshot] (delete-snapshot compute (.getRegion snapshot) (.getId snapshot))) ([compute region snapshot-id] (.deleteSnapshotInRegion (ebs-service compute) (get-region region) @@ -160,7 +160,7 @@ [v] (cond (instance? AvailabilityZoneInfo v) (.getZone v) - (instance? NodeMetadata v) (location #^NodeMetadata v) + (instance? NodeMetadata v) (location ^NodeMetadata v) (string? v) v (keyword? v) (name v) :else (throw (IllegalArgumentException. @@ -168,7 +168,7 @@ (defn attach-volume "Attaches a volume to an instance, returning the resulting org.jclouds.aws.ec2.domain.Attachment." - ([compute #^NodeMetadata node volume device] + ([compute ^NodeMetadata node volume device] (attach-volume compute node (.getProviderId node) (get-volume-id volume) device)) ([compute region instance-id volume-id device] (apply #(.attachVolumeInRegion (ebs-service compute) @@ -223,7 +223,6 @@ Note also that if :device and :node are specified, and the attach operation fails, you will have \"leaked\" the newly-created volume (volume creation and attachment cannot be done atomically)." - [compute & options] (when (-> options count odd?) (throw (IllegalArgumentException. "Must provide key-value pairs, e.g. :zone :us-east-1d :size 200"))) @@ -231,7 +230,7 @@ snapshot (get-string options :snapshot) snapshot (if (snapshot? snapshot) (.getId snapshot) snapshot) size (-?> (get-string options :size) as-int) - #^NodeMetadata node (:node options) + ^NodeMetadata node (:node options) zone (or node (get-string options :zone)) zone (if zone (get-zone zone) @@ -249,7 +248,7 @@ (defn delete-volume "Deletes a volume in the specified region." - ([compute #^Volume volume] + ([compute ^Volume volume] (delete-volume (.getRegion volume) (.getId volume))) ([compute region volume-id] (.deleteVolumeInRegion (ebs-service compute) @@ -262,29 +261,29 @@ (.getStatus k)) (defn status-available? - [#^Volume v] + [^Volume v] (= Volume$Status/AVAILABLE (status v))) (defn status-creating? - [#^Volume v] + [^Volume v] (= Volume$Status/CREATING (status v))) (defn status-deleting? - [#^Volume v] + [^Volume v] (= Volume$Status/DELETING (status v))) (defn status-in-use? - [#^Volume v] + [^Volume v] (= Volume$Status/IN_USE (status v))) (defn status-completed? - [#^Snapshot s] + [^Snapshot s] (= Snapshot$Status/COMPLETED (status s))) (defn status-error? - [#^Snapshot s] + [^Snapshot s] (= Snapshot$Status/ERROR (status s))) (defn status-pending? - [#^Snapshot s] + [^Snapshot s] (= Snapshot$Status/PENDING (status s))) \ No newline at end of file diff --git a/apis/ec2/src/main/clojure/org/jclouds/ec2/elastic_ip2.clj b/apis/ec2/src/main/clojure/org/jclouds/ec2/elastic_ip2.clj index 660f4db498..ee53f25fe9 100644 --- a/apis/ec2/src/main/clojure/org/jclouds/ec2/elastic_ip2.clj +++ b/apis/ec2/src/main/clojure/org/jclouds/ec2/elastic_ip2.clj @@ -27,10 +27,9 @@ (:import org.jclouds.compute.domain.NodeMetadata (org.jclouds.ec2.domain PublicIpInstanceIdPair))) -(defn #^org.jclouds.ec2.services.ElasticIPAddressClient +(defn ^org.jclouds.ec2.services.ElasticIPAddressClient eip-service - "Returns the synchronous ElasticIPAddressClient associated with - the specified compute service, or compute/*compute* as bound by with-compute-service." + "Returns an ElasticIPAddressClient for the given ComputeService" [compute] (-> compute .getContext .getProviderSpecificContext .getApi .getElasticIPAddressServices)) @@ -45,7 +44,7 @@ (defn associate "Associates an elastic IP address with a node." - ([compute #^NodeMetadata node public-ip] + ([compute ^NodeMetadata node public-ip] (associate node public-ip (.getProviderId node))) ([compute region public-ip instance-id] (.associateAddressInRegion (eip-service compute) @@ -62,7 +61,7 @@ You may optionally specify which IP addresses you would like to query." ([compute] (addresses compute nil)) ([compute region & public-ips] - (into {} (for [#^PublicIpInstanceIdPair pair (.describeAddressesInRegion (eip-service compute) + (into {} (for [^PublicIpInstanceIdPair pair (.describeAddressesInRegion (eip-service compute) (ebs/get-region region) (into-array String public-ips))] [(.getPublicIp pair) (merge {:region (.getRegion pair)} @@ -77,8 +76,8 @@ (defn release "Disclaims an elastic IP address from your account." - ([compute public-ip] (release compute nil public-ip)) - ([compute region public-ip] + ([compute public-ip] (release compute public-ip nil)) + ([compute public-ip region] (.releaseAddressInRegion (eip-service compute) (ebs/get-region region) public-ip))) From 9257f3a1e6a09c58b996ef535276bc5993d5a2a1 Mon Sep 17 00:00:00 2001 From: Adrian Cole Date: Fri, 3 Jun 2011 02:06:52 -0700 Subject: [PATCH 054/264] fixed typo --- .../skalicloud/SkaliCloudMalaysiaProviderMetadata.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/providers/skalicloud-sdg-my/src/main/java/org/jclouds/skalicloud/SkaliCloudMalaysiaProviderMetadata.java b/providers/skalicloud-sdg-my/src/main/java/org/jclouds/skalicloud/SkaliCloudMalaysiaProviderMetadata.java index f6db1a1553..e42c6c1185 100644 --- a/providers/skalicloud-sdg-my/src/main/java/org/jclouds/skalicloud/SkaliCloudMalaysiaProviderMetadata.java +++ b/providers/skalicloud-sdg-my/src/main/java/org/jclouds/skalicloud/SkaliCloudMalaysiaProviderMetadata.java @@ -27,7 +27,7 @@ import org.jclouds.providers.BaseProviderMetadata; import org.jclouds.providers.ProviderMetadata; /** - * Implementation of {@link org.jclouds.types.ProviderMetadata} for SkaliCloud Malasya. + * Implementation of {@link org.jclouds.types.ProviderMetadata} for SkaliCloud Malaysia. * * @author Adrian Cole */ @@ -54,7 +54,7 @@ public class SkaliCloudMalaysiaProviderMetadata extends BaseProviderMetadata { */ @Override public String getName() { - return "SkaliCloud Malasya"; + return "SkaliCloud Malaysia"; } /** From 1f535ebb6f94c43d9c5c779bae175cb9ef4f7f44 Mon Sep 17 00:00:00 2001 From: Adrian Cole Date: Fri, 3 Jun 2011 02:07:12 -0700 Subject: [PATCH 055/264] Issue 80: public acl for atmos --- .../org/jclouds/atmos/AtmosAsyncClient.java | 26 +++-- .../java/org/jclouds/atmos/AtmosClient.java | 9 +- .../atmos/blobstore/AtmosAsyncBlobStore.java | 24 +++- .../blobstore/AtmosBlobRequestSigner.java | 3 +- .../atmos/blobstore/AtmosBlobStore.java | 22 +++- .../config/AtmosBlobStoreContextModule.java | 23 ++++ .../functions/BlobToContentMetadata.java | 3 +- .../functions/ObjectToBlobMetadata.java | 18 ++- .../atmos/config/AtmosRestClientModule.java | 13 ++- .../atmos/domain/MutableContentMetadata.java | 9 ++ .../domain/internal/AtmosObjectImpl.java | 8 +- .../DelegatingMutableContentMetadata.java | 47 +++++--- .../org/jclouds/atmos/filters/ShareUrl.java | 107 ++++++++++++++++++ .../ParseObjectFromHeadersAndHttpContent.java | 27 ++++- .../ReturnTrueIfGroupACLIsOtherRead.java} | 25 ++-- .../org/jclouds/atmos/options/PutOptions.java | 65 +++++++++++ .../org/jclouds/atmos/util/AtmosUtils.java | 11 +- .../jclouds/atmos/AtmosAsyncClientTest.java | 91 +++++++++++++-- .../jclouds/atmos/AtmosClientLiveTest.java | 2 +- .../atmos/internal/StubAtmosAsyncClient.java | 24 +++- .../internal/BaseContainerLiveTest.java | 4 +- 21 files changed, 475 insertions(+), 86 deletions(-) create mode 100644 apis/atmos/src/main/java/org/jclouds/atmos/filters/ShareUrl.java rename apis/atmos/src/{test/java/org/jclouds/atmos/blobstore/functions/ObjectToBlobMetadataTest.java => main/java/org/jclouds/atmos/functions/ReturnTrueIfGroupACLIsOtherRead.java} (62%) create mode 100644 apis/atmos/src/main/java/org/jclouds/atmos/options/PutOptions.java diff --git a/apis/atmos/src/main/java/org/jclouds/atmos/AtmosAsyncClient.java b/apis/atmos/src/main/java/org/jclouds/atmos/AtmosAsyncClient.java index 3338d46e23..70e5e4af5e 100644 --- a/apis/atmos/src/main/java/org/jclouds/atmos/AtmosAsyncClient.java +++ b/apis/atmos/src/main/java/org/jclouds/atmos/AtmosAsyncClient.java @@ -44,7 +44,9 @@ import org.jclouds.atmos.functions.ParseObjectFromHeadersAndHttpContent; import org.jclouds.atmos.functions.ParseSystemMetadataFromHeaders; import org.jclouds.atmos.functions.ParseUserMetadataFromHeaders; import org.jclouds.atmos.functions.ReturnEndpointIfAlreadyExists; +import org.jclouds.atmos.functions.ReturnTrueIfGroupACLIsOtherRead; import org.jclouds.atmos.options.ListOptions; +import org.jclouds.atmos.options.PutOptions; import org.jclouds.blobstore.functions.ThrowContainerNotFoundOn404; import org.jclouds.blobstore.functions.ThrowKeyNotFoundOn404; import org.jclouds.http.options.GetOptions; @@ -107,7 +109,7 @@ public interface AtmosAsyncClient { @ExceptionParser(ReturnEndpointIfAlreadyExists.class) @Produces(MediaType.APPLICATION_OCTET_STREAM) @Consumes(MediaType.WILDCARD) - ListenableFuture createDirectory(@PathParam("directoryName") String directoryName); + ListenableFuture createDirectory(@PathParam("directoryName") String directoryName, PutOptions... options); /** * @see AtmosClient#createFile @@ -117,7 +119,8 @@ public interface AtmosAsyncClient { @Consumes(MediaType.WILDCARD) ListenableFuture createFile( @PathParam("parent") String parent, - @PathParam("name") @ParamParser(AtmosObjectName.class) @BinderParam(BindMetadataToHeaders.class) AtmosObject object); + @PathParam("name") @ParamParser(AtmosObjectName.class) @BinderParam(BindMetadataToHeaders.class) AtmosObject object, + PutOptions... options); /** * @see AtmosClient#updateFile @@ -128,7 +131,8 @@ public interface AtmosAsyncClient { @Consumes(MediaType.WILDCARD) ListenableFuture updateFile( @PathParam("parent") String parent, - @PathParam("name") @ParamParser(AtmosObjectName.class) @BinderParam(BindMetadataToHeaders.class) AtmosObject object); + @PathParam("name") @ParamParser(AtmosObjectName.class) @BinderParam(BindMetadataToHeaders.class) AtmosObject object, + PutOptions... options); /** * @see AtmosClient#readFile @@ -190,12 +194,14 @@ public interface AtmosAsyncClient { @Consumes(MediaType.WILDCARD) ListenableFuture pathExists(@PathParam("path") String path); - // signature currently doesn't work - // @POST - // @QueryParams(keys = "acl") - // @Headers(keys = { "x-emc-useracl", "x-emc-groupacl" }, values = { "root=FULL_CONTROL", - // "other=READ" }) - // @Consumes(MediaType.WILDCARD) - // void makePublic(@Endpoint URI url); + /** + * @see AtmosClient#isPublic + */ + @HEAD + @ResponseParser(ReturnTrueIfGroupACLIsOtherRead.class) + @Path("/{path}") + @Consumes(MediaType.WILDCARD) + @ExceptionParser(ReturnFalseOnNotFoundOr404.class) + ListenableFuture isPublic(@PathParam("path") String path); } diff --git a/apis/atmos/src/main/java/org/jclouds/atmos/AtmosClient.java b/apis/atmos/src/main/java/org/jclouds/atmos/AtmosClient.java index 6bcc32bb3d..02bdd2926a 100644 --- a/apis/atmos/src/main/java/org/jclouds/atmos/AtmosClient.java +++ b/apis/atmos/src/main/java/org/jclouds/atmos/AtmosClient.java @@ -27,6 +27,7 @@ import org.jclouds.atmos.domain.DirectoryEntry; import org.jclouds.atmos.domain.SystemMetadata; import org.jclouds.atmos.domain.UserMetadata; import org.jclouds.atmos.options.ListOptions; +import org.jclouds.atmos.options.PutOptions; import org.jclouds.concurrent.Timeout; import org.jclouds.http.options.GetOptions; @@ -52,13 +53,13 @@ public interface AtmosClient { BoundedSet listDirectory(String directoryName, ListOptions... options); - URI createDirectory(String directoryName); + URI createDirectory(String directoryName, PutOptions... options); @Timeout(duration = 10, timeUnit = TimeUnit.MINUTES) - URI createFile(String parent, AtmosObject object); + URI createFile(String parent, AtmosObject object, PutOptions... options); @Timeout(duration = 10, timeUnit = TimeUnit.MINUTES) - void updateFile(String parent, AtmosObject object); + void updateFile(String parent, AtmosObject object, PutOptions... options); @Timeout(duration = 10, timeUnit = TimeUnit.MINUTES) AtmosObject readFile(String path, GetOptions... options); @@ -73,4 +74,6 @@ public interface AtmosClient { boolean pathExists(String path); + boolean isPublic(String path); + } diff --git a/apis/atmos/src/main/java/org/jclouds/atmos/blobstore/AtmosAsyncBlobStore.java b/apis/atmos/src/main/java/org/jclouds/atmos/blobstore/AtmosAsyncBlobStore.java index 2f734b959c..c35eb94cb2 100644 --- a/apis/atmos/src/main/java/org/jclouds/atmos/blobstore/AtmosAsyncBlobStore.java +++ b/apis/atmos/src/main/java/org/jclouds/atmos/blobstore/AtmosAsyncBlobStore.java @@ -19,8 +19,10 @@ package org.jclouds.atmos.blobstore; import static com.google.common.base.Preconditions.checkNotNull; +import static org.jclouds.atmos.options.PutOptions.Builder.publicRead; import java.net.URI; +import java.util.Map; import java.util.Set; import java.util.concurrent.Callable; import java.util.concurrent.ExecutorService; @@ -79,6 +81,7 @@ public class AtmosAsyncBlobStore extends BaseAsyncBlobStore { private final Crypto crypto; private final BlobToHttpGetOptions blob2ObjectGetOptions; private final Provider fetchBlobMetadataProvider; + private final Map isPublic; @Inject AtmosAsyncBlobStore(BlobStoreContext context, BlobUtils blobUtils, @@ -87,7 +90,8 @@ public class AtmosAsyncBlobStore extends BaseAsyncBlobStore { ObjectToBlob object2Blob, ObjectToBlobMetadata object2BlobMd, BlobToObject blob2Object, BlobStoreListOptionsToListOptions container2ContainerListOptions, DirectoryEntryListToResourceMetadataList container2ResourceList, Crypto crypto, - BlobToHttpGetOptions blob2ObjectGetOptions, Provider fetchBlobMetadataProvider) { + BlobToHttpGetOptions blob2ObjectGetOptions, Provider fetchBlobMetadataProvider, + Map isPublic) { super(context, blobUtils, service, defaultLocation, locations); this.blob2ObjectGetOptions = checkNotNull(blob2ObjectGetOptions, "blob2ObjectGetOptions"); this.sync = checkNotNull(sync, "sync"); @@ -100,6 +104,7 @@ public class AtmosAsyncBlobStore extends BaseAsyncBlobStore { this.object2BlobMd = checkNotNull(object2BlobMd, "object2BlobMd"); this.crypto = checkNotNull(crypto, "crypto"); this.fetchBlobMetadataProvider = checkNotNull(fetchBlobMetadataProvider, "fetchBlobMetadataProvider"); + this.isPublic = checkNotNull(isPublic, "isPublic"); } /** @@ -231,11 +236,18 @@ public class AtmosAsyncBlobStore extends BaseAsyncBlobStore { */ @Override public ListenableFuture putBlob(final String container, final Blob blob) { + final org.jclouds.atmos.options.PutOptions options = new org.jclouds.atmos.options.PutOptions(); + try { + if (isPublic.get(container + "/")) + options.publicRead(); + } catch (NullPointerException e) { + // MapMaker + } return Futures.makeListenable(service.submit(new Callable() { @Override public String call() throws Exception { - return AtmosUtils.putBlob(sync, crypto, blob2Object, container, blob); + return AtmosUtils.putBlob(sync, crypto, blob2Object, container, blob, options); } @Override @@ -264,7 +276,13 @@ public class AtmosAsyncBlobStore extends BaseAsyncBlobStore { public ListenableFuture createContainerInLocation(Location location, String container, CreateContainerOptions options) { if (options.isPublicRead()) - throw new UnsupportedOperationException("publicRead"); + return Futures.compose(async.createDirectory(container, publicRead()), new Function() { + + public Boolean apply(URI from) { + return true; + } + + }, service); return createContainerInLocation(location, container); } diff --git a/apis/atmos/src/main/java/org/jclouds/atmos/blobstore/AtmosBlobRequestSigner.java b/apis/atmos/src/main/java/org/jclouds/atmos/blobstore/AtmosBlobRequestSigner.java index b05a9c71c7..6c89c6cf08 100644 --- a/apis/atmos/src/main/java/org/jclouds/atmos/blobstore/AtmosBlobRequestSigner.java +++ b/apis/atmos/src/main/java/org/jclouds/atmos/blobstore/AtmosBlobRequestSigner.java @@ -29,6 +29,7 @@ import javax.inject.Singleton; import org.jclouds.atmos.AtmosAsyncClient; import org.jclouds.atmos.blobstore.functions.BlobToObject; import org.jclouds.atmos.domain.AtmosObject; +import org.jclouds.atmos.options.PutOptions; import org.jclouds.blobstore.BlobRequestSigner; import org.jclouds.blobstore.domain.Blob; import org.jclouds.blobstore.functions.BlobToHttpGetOptions; @@ -58,7 +59,7 @@ public class AtmosBlobRequestSigner implements BlobRequestSigner { this.blob2ObjectGetOptions = checkNotNull(blob2ObjectGetOptions, "blob2ObjectGetOptions"); this.getMethod = AtmosAsyncClient.class.getMethod("readFile", String.class, GetOptions[].class); this.deleteMethod = AtmosAsyncClient.class.getMethod("deletePath", String.class); - this.createMethod = AtmosAsyncClient.class.getMethod("createFile", String.class, AtmosObject.class); + this.createMethod = AtmosAsyncClient.class.getMethod("createFile", String.class, AtmosObject.class, PutOptions[].class); } @Override diff --git a/apis/atmos/src/main/java/org/jclouds/atmos/blobstore/AtmosBlobStore.java b/apis/atmos/src/main/java/org/jclouds/atmos/blobstore/AtmosBlobStore.java index a61d15c740..20f05d3311 100644 --- a/apis/atmos/src/main/java/org/jclouds/atmos/blobstore/AtmosBlobStore.java +++ b/apis/atmos/src/main/java/org/jclouds/atmos/blobstore/AtmosBlobStore.java @@ -19,7 +19,9 @@ package org.jclouds.atmos.blobstore; import static com.google.common.base.Preconditions.checkNotNull; +import static org.jclouds.atmos.options.PutOptions.Builder.publicRead; +import java.util.Map; import java.util.Set; import javax.inject.Inject; @@ -67,6 +69,7 @@ public class AtmosBlobStore extends BaseBlobStore { private final Crypto crypto; private final BlobToHttpGetOptions blob2ObjectGetOptions; private final Provider fetchBlobMetadataProvider; + private final Map isPublic; @Inject AtmosBlobStore(BlobStoreContext context, BlobUtils blobUtils, Supplier defaultLocation, @@ -74,7 +77,8 @@ public class AtmosBlobStore extends BaseBlobStore { ObjectToBlobMetadata object2BlobMd, BlobToObject blob2Object, BlobStoreListOptionsToListOptions container2ContainerListOptions, DirectoryEntryListToResourceMetadataList container2ResourceList, Crypto crypto, - BlobToHttpGetOptions blob2ObjectGetOptions, Provider fetchBlobMetadataProvider) { + BlobToHttpGetOptions blob2ObjectGetOptions, Provider fetchBlobMetadataProvider, + Map isPublic) { super(context, blobUtils, defaultLocation, locations); this.blob2ObjectGetOptions = checkNotNull(blob2ObjectGetOptions, "blob2ObjectGetOptions"); this.sync = checkNotNull(sync, "sync"); @@ -86,6 +90,7 @@ public class AtmosBlobStore extends BaseBlobStore { this.object2BlobMd = checkNotNull(object2BlobMd, "object2BlobMd"); this.crypto = checkNotNull(crypto, "crypto"); this.fetchBlobMetadataProvider = checkNotNull(fetchBlobMetadataProvider, "fetchBlobMetadataProvider"); + this.isPublic = checkNotNull(isPublic, "isPublic"); } /** @@ -205,7 +210,14 @@ public class AtmosBlobStore extends BaseBlobStore { */ @Override public String putBlob(final String container, final Blob blob) { - return AtmosUtils.putBlob(sync, crypto, blob2Object, container, blob); + final org.jclouds.atmos.options.PutOptions options = new org.jclouds.atmos.options.PutOptions(); + try { + if (isPublic.get(container + "/")) + options.publicRead(); + } catch (NullPointerException e) { + // MapMaker + } + return AtmosUtils.putBlob(sync, crypto, blob2Object, container, blob, options); } /** @@ -229,8 +241,10 @@ public class AtmosBlobStore extends BaseBlobStore { @Override public boolean createContainerInLocation(Location location, String container, CreateContainerOptions options) { - if (options.isPublicRead()) - throw new UnsupportedOperationException("publicRead"); + if (options.isPublicRead()) { + sync.createDirectory(container, publicRead()); + return true; + } return createContainerInLocation(location, container); } } diff --git a/apis/atmos/src/main/java/org/jclouds/atmos/blobstore/config/AtmosBlobStoreContextModule.java b/apis/atmos/src/main/java/org/jclouds/atmos/blobstore/config/AtmosBlobStoreContextModule.java index 28002f41d5..0ed985f95b 100644 --- a/apis/atmos/src/main/java/org/jclouds/atmos/blobstore/config/AtmosBlobStoreContextModule.java +++ b/apis/atmos/src/main/java/org/jclouds/atmos/blobstore/config/AtmosBlobStoreContextModule.java @@ -18,6 +18,11 @@ */ package org.jclouds.atmos.blobstore.config; +import java.util.Map; +import java.util.concurrent.TimeUnit; + +import javax.inject.Singleton; + import org.jclouds.atmos.AtmosAsyncClient; import org.jclouds.atmos.AtmosClient; import org.jclouds.atmos.blobstore.AtmosAsyncBlobStore; @@ -34,7 +39,10 @@ import org.jclouds.blobstore.internal.BlobStoreContextImpl; import org.jclouds.blobstore.strategy.ContainsValueInListStrategy; import org.jclouds.location.config.JustProviderLocationModule; +import com.google.common.base.Function; +import com.google.common.collect.MapMaker; import com.google.inject.AbstractModule; +import com.google.inject.Provides; import com.google.inject.Scopes; import com.google.inject.TypeLiteral; @@ -57,4 +65,19 @@ public class AtmosBlobStoreContextModule extends AbstractModule { bind(BlobRequestSigner.class).to(AtmosBlobRequestSigner.class); install(new JustProviderLocationModule()); } + + @Provides + @Singleton + protected Map isPublic(final AtmosClient client) { + return new MapMaker().expireAfterWrite(30, TimeUnit.SECONDS).makeComputingMap(new Function() { + public Boolean apply(String directory) { + return client.isPublic(directory); + } + + @Override + public String toString() { + return "isPublic()"; + } + }); + } } diff --git a/apis/atmos/src/main/java/org/jclouds/atmos/blobstore/functions/BlobToContentMetadata.java b/apis/atmos/src/main/java/org/jclouds/atmos/blobstore/functions/BlobToContentMetadata.java index a8798158fe..207246f586 100644 --- a/apis/atmos/src/main/java/org/jclouds/atmos/blobstore/functions/BlobToContentMetadata.java +++ b/apis/atmos/src/main/java/org/jclouds/atmos/blobstore/functions/BlobToContentMetadata.java @@ -36,7 +36,8 @@ public class BlobToContentMetadata implements Function { private final AtmosObjectName objectName; - private static final Set systemMetadata = ImmutableSet.of("atime", "mtime", "ctime", - "itime", "type", "uid", "gid", "objectid", "objname", "size", "nlink", "policyname", - "content-md5"); + private final ShareUrl shareUrl; + + private static final Set systemMetadata = ImmutableSet.of("atime", "mtime", "ctime", "itime", "type", "uid", + "gid", "objectid", "objname", "size", "nlink", "policyname", "content-md5"); @Inject - protected ObjectToBlobMetadata(AtmosObjectName objectName) { + protected ObjectToBlobMetadata(AtmosObjectName objectName, ShareUrl shareUrl) + throws SecurityException, NoSuchMethodException { this.objectName = objectName; + this.shareUrl = shareUrl; } public MutableBlobMetadata apply(AtmosObject from) { @@ -60,6 +66,10 @@ public class ObjectToBlobMetadata implements Function provideTimeStampCache(@Named(Constants.PROPERTY_SESSION_INTERVAL) long seconds, - final DateService dateService) { + final DateService dateService) { return Suppliers.memoizeWithExpiration(new Supplier() { public String get() { return dateService.rfc822DateFormat(); @@ -82,6 +83,12 @@ public class AtmosRestClientModule extends RestClientModule allHeaders = LinkedHashMultimap.create(); public AtmosObjectImpl(MutableContentMetadata contentMetadata, SystemMetadata systemMetadata, - UserMetadata userMetadata) { + UserMetadata userMetadata) { this.contentMetadata = contentMetadata; this.systemMetadata = systemMetadata; this.userMetadata = userMetadata; @@ -165,7 +165,7 @@ public class AtmosObjectImpl extends PayloadEnclosingImpl implements AtmosObject @Override public void setPayload(Payload data) { this.payload = data; - this.contentMetadata = new DelegatingMutableContentMetadata(contentMetadata.getName(), - payload.getContentMetadata()); + this.contentMetadata = new DelegatingMutableContentMetadata(contentMetadata.getUri(), contentMetadata.getName(), + contentMetadata.getPath(), payload.getContentMetadata()); } } diff --git a/apis/atmos/src/main/java/org/jclouds/atmos/domain/internal/DelegatingMutableContentMetadata.java b/apis/atmos/src/main/java/org/jclouds/atmos/domain/internal/DelegatingMutableContentMetadata.java index c00b288d6b..ce9c56290b 100644 --- a/apis/atmos/src/main/java/org/jclouds/atmos/domain/internal/DelegatingMutableContentMetadata.java +++ b/apis/atmos/src/main/java/org/jclouds/atmos/domain/internal/DelegatingMutableContentMetadata.java @@ -18,6 +18,8 @@ */ package org.jclouds.atmos.domain.internal; +import java.net.URI; + import org.jclouds.atmos.domain.MutableContentMetadata; import org.jclouds.io.ContentMetadataBuilder; import org.jclouds.io.payloads.BaseMutableContentMetadata; @@ -29,16 +31,21 @@ import com.google.common.collect.Multimap; * @author Adrian Cole */ public class DelegatingMutableContentMetadata implements MutableContentMetadata { + private URI uri; private String name; + private String path; private final org.jclouds.io.MutableContentMetadata delegate; public DelegatingMutableContentMetadata() { - this(null, new BaseMutableContentMetadata()); + this(null, null, null, new BaseMutableContentMetadata()); } - public DelegatingMutableContentMetadata(String name, org.jclouds.io.MutableContentMetadata delegate) { + public DelegatingMutableContentMetadata(URI uri, String name, String path, + org.jclouds.io.MutableContentMetadata delegate) { + this.uri = uri; this.name = name; this.delegate = delegate; + this.path = path; } @Override @@ -90,15 +97,10 @@ public class DelegatingMutableContentMetadata implements MutableContentMetadata if (getClass() != obj.getClass()) return false; DelegatingMutableContentMetadata other = (DelegatingMutableContentMetadata) obj; - if (delegate == null) { - if (other.delegate != null) + if (uri == null) { + if (other.uri != null) return false; - } else if (!delegate.equals(other.delegate)) - return false; - if (name == null) { - if (other.name != null) - return false; - } else if (!name.equals(other.name)) + } else if (!uri.equals(other.uri)) return false; return true; } @@ -107,14 +109,13 @@ public class DelegatingMutableContentMetadata implements MutableContentMetadata public int hashCode() { final int prime = 31; int result = 1; - result = prime * result + ((delegate == null) ? 0 : delegate.hashCode()); - result = prime * result + ((name == null) ? 0 : name.hashCode()); + result = prime * result + ((uri == null) ? 0 : uri.hashCode()); return result; } @Override public String toString() { - return "[name=" + name + ", delegate=" + delegate + "]"; + return "[uri=" + uri + ", name=" + name + ", path=" + path + ", delegate=" + delegate + "]"; } public org.jclouds.io.MutableContentMetadata getDelegate() { @@ -162,4 +163,24 @@ public class DelegatingMutableContentMetadata implements MutableContentMetadata return delegate.toBuilder(); } + @Override + public URI getUri() { + return uri; + } + + @Override + public void setUri(URI uri) { + this.uri = uri; + } + + @Override + public String getPath() { + return path; + } + + @Override + public void setPath(String path) { + this.path = path; + } + } diff --git a/apis/atmos/src/main/java/org/jclouds/atmos/filters/ShareUrl.java b/apis/atmos/src/main/java/org/jclouds/atmos/filters/ShareUrl.java new file mode 100644 index 0000000000..585cc64150 --- /dev/null +++ b/apis/atmos/src/main/java/org/jclouds/atmos/filters/ShareUrl.java @@ -0,0 +1,107 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.jclouds.atmos.filters; + +import static org.jclouds.Constants.LOGGER_SIGNATURE; +import static org.jclouds.Constants.PROPERTY_CREDENTIAL; +import static org.jclouds.Constants.PROPERTY_IDENTITY; + +import java.net.URI; + +import javax.annotation.Resource; +import javax.inject.Inject; +import javax.inject.Named; +import javax.inject.Singleton; +import javax.ws.rs.core.UriBuilder; + +import org.jclouds.crypto.Crypto; +import org.jclouds.crypto.CryptoStreams; +import org.jclouds.date.TimeStamp; +import org.jclouds.http.HttpException; +import org.jclouds.io.InputSuppliers; +import org.jclouds.location.Provider; +import org.jclouds.logging.Logger; + +import com.google.common.base.Function; + +/** + * Signs the EMC Atmos Online Storage request. + * + * @see + * @author Adrian Cole + * + */ +@Singleton +public class ShareUrl implements Function { + + private final String uid; + private final byte[] key; + private final URI provider; + private final javax.inject.Provider timeStampProvider; + private final javax.inject.Provider uriBuilders; + private final Crypto crypto; + + @Resource + Logger logger = Logger.NULL; + + @Resource + @Named(LOGGER_SIGNATURE) + Logger signatureLog = Logger.NULL; + + @Inject + public ShareUrl(@Named(PROPERTY_IDENTITY) String uid, @Named(PROPERTY_CREDENTIAL) String encodedKey, + @Provider URI provider, @TimeStamp javax.inject.Provider timeStampProvider, + javax.inject.Provider uriBuilders, Crypto crypto) { + this.uid = uid; + this.key = CryptoStreams.base64(encodedKey); + this.provider = provider; + this.uriBuilders = uriBuilders; + this.timeStampProvider = timeStampProvider; + this.crypto = crypto; + } + + @Override + public URI apply(String path) throws HttpException { + String requestedResource = new StringBuilder().append("/rest/namespace/").append(path).toString(); + long expires = timeStampProvider.get(); + String signature = signString(createStringToSign(requestedResource, expires)); + return uriBuilders.get().uri(provider).path(requestedResource).queryParam("uid", uid).queryParam("expires", + expires).queryParam("signature", signature).build(); + } + + public String createStringToSign(String requestedResource, long expires) { + StringBuilder toSign = new StringBuilder(); + toSign.append("GET\n"); + toSign.append(requestedResource.toLowerCase()).append("\n"); + toSign.append(uid).append("\n"); + toSign.append(expires); + return toSign.toString(); + } + + public String signString(String toSign) { + String signature; + try { + signature = CryptoStreams.base64(CryptoStreams.mac(InputSuppliers.of(toSign), crypto.hmacSHA1(key))); + } catch (Exception e) { + throw new HttpException("error signing request", e); + } + return signature; + } + +} diff --git a/apis/atmos/src/main/java/org/jclouds/atmos/functions/ParseObjectFromHeadersAndHttpContent.java b/apis/atmos/src/main/java/org/jclouds/atmos/functions/ParseObjectFromHeadersAndHttpContent.java index 28cf0e694a..2b59be1d54 100644 --- a/apis/atmos/src/main/java/org/jclouds/atmos/functions/ParseObjectFromHeadersAndHttpContent.java +++ b/apis/atmos/src/main/java/org/jclouds/atmos/functions/ParseObjectFromHeadersAndHttpContent.java @@ -21,12 +21,16 @@ package org.jclouds.atmos.functions; import static com.google.common.base.Preconditions.checkNotNull; import static org.jclouds.http.HttpUtils.attemptToParseSizeAndRangeFromHeaders; +import java.net.URI; + import javax.inject.Inject; -import javax.inject.Singleton; import org.jclouds.atmos.domain.AtmosObject; import org.jclouds.blobstore.functions.ParseSystemAndUserMetadataFromHeaders; +import org.jclouds.http.HttpRequest; import org.jclouds.http.HttpResponse; +import org.jclouds.rest.InvocationContext; +import org.jclouds.rest.internal.GeneratedHttpRequest; import com.google.common.base.Function; @@ -36,16 +40,18 @@ import com.google.common.base.Function; * @see ParseMetadataFromHeaders * @author Adrian Cole */ -@Singleton -public class ParseObjectFromHeadersAndHttpContent implements Function { +public class ParseObjectFromHeadersAndHttpContent implements Function, + InvocationContext { private final ParseSystemMetadataFromHeaders systemMetadataParser; private final ParseUserMetadataFromHeaders userMetadataParser; private final AtmosObject.Factory objectProvider; + private URI uri; + private String path; @Inject public ParseObjectFromHeadersAndHttpContent(ParseSystemMetadataFromHeaders systemMetadataParser, - ParseUserMetadataFromHeaders userMetadataParser, AtmosObject.Factory objectProvider) { + ParseUserMetadataFromHeaders userMetadataParser, AtmosObject.Factory objectProvider) { this.systemMetadataParser = checkNotNull(systemMetadataParser, "systemMetadataParser"); this.userMetadataParser = checkNotNull(userMetadataParser, "userMetadataParser"); this.objectProvider = checkNotNull(objectProvider, "objectProvider"); @@ -63,9 +69,22 @@ public class ParseObjectFromHeadersAndHttpContent implements Function { - public void testFromWhenTypeIsDirectory() { - Injector injector = Guice.createInjector(); - injector.getInstance(ObjectToBlobMetadata.class); - - assertEquals("", ""); + public Boolean apply(HttpResponse from) { + checkNotNull(from, "http response"); + return from.getHeaders().containsEntry("x-emc-groupacl", "other=READ"); } } diff --git a/apis/atmos/src/main/java/org/jclouds/atmos/options/PutOptions.java b/apis/atmos/src/main/java/org/jclouds/atmos/options/PutOptions.java new file mode 100644 index 0000000000..6566eb91ac --- /dev/null +++ b/apis/atmos/src/main/java/org/jclouds/atmos/options/PutOptions.java @@ -0,0 +1,65 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.jclouds.atmos.options; + +import org.jclouds.http.options.BaseHttpRequestOptions; + +/** + * Contains options supported in the REST API for the PUT operations. + *

+ *

+ * Usage

The recommended way to instantiate a PutOptions object is to statically import + * PutOptions.Builder.* and invoke a static creation method followed by an instance mutator (if + * needed): + *

+ * + * import org.jclouds.atmos.options.PutOptions.Builder.* + * import org.jclouds.atmos.AtmosClient; + * + * AtmosClient connection = // get connection + * connection.createDirectory("directory", publicRead()); + * + * + * @author Adrian Cole + * + */ +public class PutOptions extends BaseHttpRequestOptions { + public static final PutOptions NONE = new PutOptions(); + + /** + * Add public access to all users + * + */ + public PutOptions publicRead() { + this.replaceHeader("x-emc-useracl", "root=FULL_CONTROL"); + this.replaceHeader("x-emc-groupacl", "other=READ"); + return this; + } + + public static class Builder { + + /** + * @see PutOptions#publicRead + */ + public static PutOptions publicRead() { + PutOptions options = new PutOptions(); + return options.publicRead(); + } + } +} diff --git a/apis/atmos/src/main/java/org/jclouds/atmos/util/AtmosUtils.java b/apis/atmos/src/main/java/org/jclouds/atmos/util/AtmosUtils.java index 816f6163dc..46923bc20a 100644 --- a/apis/atmos/src/main/java/org/jclouds/atmos/util/AtmosUtils.java +++ b/apis/atmos/src/main/java/org/jclouds/atmos/util/AtmosUtils.java @@ -28,6 +28,7 @@ import org.jclouds.atmos.AtmosClient; import org.jclouds.atmos.blobstore.functions.BlobToObject; import org.jclouds.atmos.domain.AtmosError; import org.jclouds.atmos.filters.SignRequest; +import org.jclouds.atmos.options.PutOptions; import org.jclouds.atmos.xml.ErrorHandler; import org.jclouds.blobstore.domain.Blob; import org.jclouds.crypto.Crypto; @@ -56,8 +57,8 @@ public class AtmosUtils { @Inject Provider errorHandlerProvider; - public AtmosError parseAtmosErrorFromContent(HttpCommand command, HttpResponse response, - InputStream content) throws HttpException { + public AtmosError parseAtmosErrorFromContent(HttpCommand command, HttpResponse response, InputStream content) + throws HttpException { AtmosError error = (AtmosError) factory.create(errorHandlerProvider.get()).parse(content); if (error.getCode() == 1032) { error.setStringSigned(signer.createStringToSign(command.getCurrentRequest())); @@ -66,11 +67,11 @@ public class AtmosUtils { } - public static String putBlob(final AtmosClient sync, Crypto crypto, BlobToObject blob2Object, - String container, Blob blob) { + public static String putBlob(final AtmosClient sync, Crypto crypto, BlobToObject blob2Object, String container, + Blob blob, PutOptions options) { final String path = container + "/" + blob.getMetadata().getName(); deleteAndEnsureGone(sync, path); - sync.createFile(container, blob2Object.apply(blob)); + sync.createFile(container, blob2Object.apply(blob), options); return path; } diff --git a/apis/atmos/src/test/java/org/jclouds/atmos/AtmosAsyncClientTest.java b/apis/atmos/src/test/java/org/jclouds/atmos/AtmosAsyncClientTest.java index e47086ee0d..324f137674 100644 --- a/apis/atmos/src/test/java/org/jclouds/atmos/AtmosAsyncClientTest.java +++ b/apis/atmos/src/test/java/org/jclouds/atmos/AtmosAsyncClientTest.java @@ -21,7 +21,6 @@ package org.jclouds.atmos; import static org.testng.Assert.assertEquals; import java.io.IOException; -import java.lang.reflect.Array; import java.lang.reflect.Method; import java.util.Properties; @@ -35,7 +34,9 @@ import org.jclouds.atmos.functions.ParseDirectoryListFromContentAndHeaders; import org.jclouds.atmos.functions.ParseObjectFromHeadersAndHttpContent; import org.jclouds.atmos.functions.ParseSystemMetadataFromHeaders; import org.jclouds.atmos.functions.ReturnEndpointIfAlreadyExists; +import org.jclouds.atmos.functions.ReturnTrueIfGroupACLIsOtherRead; import org.jclouds.atmos.options.ListOptions; +import org.jclouds.atmos.options.PutOptions; import org.jclouds.blobstore.binders.BindBlobToMultipartFormTest; import org.jclouds.blobstore.functions.ThrowContainerNotFoundOn404; import org.jclouds.blobstore.functions.ThrowKeyNotFoundOn404; @@ -49,6 +50,7 @@ import org.jclouds.rest.ConfiguresRestClient; import org.jclouds.rest.RestClientTest; import org.jclouds.rest.RestContextFactory; import org.jclouds.rest.RestContextSpec; +import org.jclouds.rest.functions.ReturnFalseOnNotFoundOr404; import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404; import org.jclouds.rest.functions.ReturnVoidOnNotFoundOr404; import org.jclouds.rest.internal.RestAnnotationProcessor; @@ -71,8 +73,7 @@ public class AtmosAsyncClientTest extends RestClientTest { private BlobToObject blobToObject; public void testListDirectories() throws SecurityException, NoSuchMethodException, IOException { - Method method = AtmosAsyncClient.class.getMethod("listDirectories", Array.newInstance(ListOptions.class, 0) - .getClass()); + Method method = AtmosAsyncClient.class.getMethod("listDirectories", ListOptions[].class); HttpRequest request = processor.createRequest(method); assertRequestLineEquals(request, "GET https://accesspoint.atmosonline.com/rest/namespace HTTP/1.1"); @@ -87,8 +88,7 @@ public class AtmosAsyncClientTest extends RestClientTest { } public void testListDirectory() throws SecurityException, NoSuchMethodException, IOException { - Method method = AtmosAsyncClient.class.getMethod("listDirectory", String.class, Array.newInstance( - ListOptions.class, 0).getClass()); + Method method = AtmosAsyncClient.class.getMethod("listDirectory", String.class, ListOptions[].class); HttpRequest request = processor.createRequest(method, "directory"); assertRequestLineEquals(request, "GET https://accesspoint.atmosonline.com/rest/namespace/directory/ HTTP/1.1"); @@ -103,8 +103,7 @@ public class AtmosAsyncClientTest extends RestClientTest { } public void testListDirectoriesOptions() throws SecurityException, NoSuchMethodException, IOException { - Method method = AtmosAsyncClient.class.getMethod("listDirectories", Array.newInstance(ListOptions.class, 0) - .getClass()); + Method method = AtmosAsyncClient.class.getMethod("listDirectories", ListOptions[].class); HttpRequest request = processor.createRequest(method, new ListOptions().limit(1).token("asda")); assertRequestLineEquals(request, "GET https://accesspoint.atmosonline.com/rest/namespace HTTP/1.1"); @@ -119,8 +118,7 @@ public class AtmosAsyncClientTest extends RestClientTest { } public void testListDirectoryOptions() throws SecurityException, NoSuchMethodException, IOException { - Method method = AtmosAsyncClient.class.getMethod("listDirectory", String.class, Array.newInstance( - ListOptions.class, 0).getClass()); + Method method = AtmosAsyncClient.class.getMethod("listDirectory", String.class, ListOptions[].class); HttpRequest request = processor.createRequest(method, "directory", new ListOptions().limit(1).token("asda")); assertRequestLineEquals(request, "GET https://accesspoint.atmosonline.com/rest/namespace/directory/ HTTP/1.1"); @@ -135,7 +133,7 @@ public class AtmosAsyncClientTest extends RestClientTest { } public void testCreateDirectory() throws SecurityException, NoSuchMethodException, IOException { - Method method = AtmosAsyncClient.class.getMethod("createDirectory", String.class); + Method method = AtmosAsyncClient.class.getMethod("createDirectory", String.class, PutOptions[].class); HttpRequest request = processor.createRequest(method, "dir"); assertRequestLineEquals(request, "POST https://accesspoint.atmosonline.com/rest/namespace/dir/ HTTP/1.1"); @@ -149,8 +147,25 @@ public class AtmosAsyncClientTest extends RestClientTest { checkFilters(request); } + public void testCreateDirectoryOptions() throws SecurityException, NoSuchMethodException, IOException { + Method method = AtmosAsyncClient.class.getMethod("createDirectory", String.class, PutOptions[].class); + HttpRequest request = processor.createRequest(method, "dir", PutOptions.Builder.publicRead()); + + assertRequestLineEquals(request, "POST https://accesspoint.atmosonline.com/rest/namespace/dir/ HTTP/1.1"); + assertNonPayloadHeadersEqual(request, HttpHeaders.ACCEPT + + ": */*\nx-emc-groupacl: other=READ\nx-emc-useracl: root=FULL_CONTROL\n"); + assertPayloadEquals(request, "", "application/octet-stream", false); + + assertResponseParserClassEquals(method, request, ParseURIFromListOrLocationHeaderIf20x.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, ReturnEndpointIfAlreadyExists.class); + + checkFilters(request); + } + public void testCreateFile() throws SecurityException, NoSuchMethodException, IOException { - Method method = AtmosAsyncClient.class.getMethod("createFile", String.class, AtmosObject.class); + Method method = AtmosAsyncClient.class.getMethod("createFile", String.class, AtmosObject.class, + PutOptions[].class); HttpRequest request = processor.createRequest(method, "dir", blobToObject .apply(BindBlobToMultipartFormTest.TEST_BLOB)); @@ -165,8 +180,27 @@ public class AtmosAsyncClientTest extends RestClientTest { checkFilters(request); } + public void testCreateFileOptions() throws SecurityException, NoSuchMethodException, IOException { + Method method = AtmosAsyncClient.class.getMethod("createFile", String.class, AtmosObject.class, + PutOptions[].class); + HttpRequest request = processor.createRequest(method, "dir", blobToObject + .apply(BindBlobToMultipartFormTest.TEST_BLOB), PutOptions.Builder.publicRead()); + + assertRequestLineEquals(request, "POST https://accesspoint.atmosonline.com/rest/namespace/dir/hello HTTP/1.1"); + assertNonPayloadHeadersEqual(request, HttpHeaders.ACCEPT + + ": */*\nx-emc-groupacl: other=READ\nx-emc-useracl: root=FULL_CONTROL\n"); + assertPayloadEquals(request, "hello", "text/plain", false); + + assertResponseParserClassEquals(method, request, ParseURIFromListOrLocationHeaderIf20x.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); + + checkFilters(request); + } + public void testUpdateFile() throws SecurityException, NoSuchMethodException, IOException { - Method method = AtmosAsyncClient.class.getMethod("updateFile", String.class, AtmosObject.class); + Method method = AtmosAsyncClient.class.getMethod("updateFile", String.class, AtmosObject.class, + PutOptions[].class); HttpRequest request = processor.createRequest(method, "dir", blobToObject .apply(BindBlobToMultipartFormTest.TEST_BLOB)); @@ -181,6 +215,24 @@ public class AtmosAsyncClientTest extends RestClientTest { checkFilters(request); } + public void testUpdateFileOptions() throws SecurityException, NoSuchMethodException, IOException { + Method method = AtmosAsyncClient.class.getMethod("updateFile", String.class, AtmosObject.class, + PutOptions[].class); + HttpRequest request = processor.createRequest(method, "dir", blobToObject + .apply(BindBlobToMultipartFormTest.TEST_BLOB), PutOptions.Builder.publicRead()); + + assertRequestLineEquals(request, "PUT https://accesspoint.atmosonline.com/rest/namespace/dir/hello HTTP/1.1"); + assertNonPayloadHeadersEqual(request, HttpHeaders.ACCEPT + + ": */*\nx-emc-groupacl: other=READ\nx-emc-useracl: root=FULL_CONTROL\n"); + assertPayloadEquals(request, "hello", "text/plain", false); + + assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, ThrowKeyNotFoundOn404.class); + + checkFilters(request); + } + public void testReadFile() throws SecurityException, NoSuchMethodException, IOException { Method method = AtmosAsyncClient.class.getMethod("readFile", String.class, GetOptions[].class); HttpRequest request = processor.createRequest(method, "dir/file"); @@ -226,6 +278,21 @@ public class AtmosAsyncClientTest extends RestClientTest { checkFilters(request); } + public void testIsPublic() throws SecurityException, NoSuchMethodException, IOException { + Method method = AtmosAsyncClient.class.getMethod("isPublic", String.class); + HttpRequest request = processor.createRequest(method, "dir/file"); + + assertRequestLineEquals(request, "HEAD https://accesspoint.atmosonline.com/rest/namespace/dir/file HTTP/1.1"); + assertNonPayloadHeadersEqual(request, HttpHeaders.ACCEPT + ": */*\n"); + assertPayloadEquals(request, null, null, false); + + assertResponseParserClassEquals(method, request, ReturnTrueIfGroupACLIsOtherRead.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, ReturnFalseOnNotFoundOr404.class); + + checkFilters(request); + } + public void testNewObject() throws SecurityException, NoSuchMethodException, IOException { Method method = AtmosAsyncClient.class.getMethod("newObject"); assertEquals(method.getReturnType(), AtmosObject.class); diff --git a/apis/atmos/src/test/java/org/jclouds/atmos/AtmosClientLiveTest.java b/apis/atmos/src/test/java/org/jclouds/atmos/AtmosClientLiveTest.java index b6a336625b..98f5e90dc0 100644 --- a/apis/atmos/src/test/java/org/jclouds/atmos/AtmosClientLiveTest.java +++ b/apis/atmos/src/test/java/org/jclouds/atmos/AtmosClientLiveTest.java @@ -53,7 +53,7 @@ import com.google.common.collect.Sets; * * @author Adrian Cole */ -@Test(groups = "live", sequential = true) +@Test(groups = "live", singleThreaded = true) public class AtmosClientLiveTest extends BaseBlobStoreIntegrationTest { public AtmosClient getApi() { diff --git a/apis/atmos/src/test/java/org/jclouds/atmos/internal/StubAtmosAsyncClient.java b/apis/atmos/src/test/java/org/jclouds/atmos/internal/StubAtmosAsyncClient.java index 0b42ca1dbe..498d97eb49 100644 --- a/apis/atmos/src/test/java/org/jclouds/atmos/internal/StubAtmosAsyncClient.java +++ b/apis/atmos/src/test/java/org/jclouds/atmos/internal/StubAtmosAsyncClient.java @@ -42,6 +42,7 @@ import org.jclouds.atmos.domain.DirectoryEntry; import org.jclouds.atmos.domain.SystemMetadata; import org.jclouds.atmos.domain.UserMetadata; import org.jclouds.atmos.options.ListOptions; +import org.jclouds.atmos.options.PutOptions; import org.jclouds.blobstore.TransientAsyncBlobStore; import org.jclouds.blobstore.domain.Blob; import org.jclouds.blobstore.domain.BlobMetadata; @@ -87,7 +88,8 @@ public class StubAtmosAsyncClient implements AtmosAsyncClient { this.service = service; } - public ListenableFuture createDirectory(String directoryName) { + @Override + public ListenableFuture createDirectory(String directoryName, PutOptions... options) { final String container; final String path; if (directoryName.indexOf('/') != -1) { @@ -112,7 +114,8 @@ public class StubAtmosAsyncClient implements AtmosAsyncClient { }, service); } - public ListenableFuture createFile(String parent, AtmosObject object) { + @Override + public ListenableFuture createFile(String parent, AtmosObject object, PutOptions... options) { final String uri = "http://stub/containers/" + parent + "/" + object.getContentMetadata().getName(); String file = object.getContentMetadata().getName(); String container = parent; @@ -132,6 +135,7 @@ public class StubAtmosAsyncClient implements AtmosAsyncClient { }, service); } + @Override public ListenableFuture deletePath(String path) { if (path.indexOf('/') == path.length() - 1) { // chop off the trailing slash @@ -150,10 +154,12 @@ public class StubAtmosAsyncClient implements AtmosAsyncClient { } } + @Override public ListenableFuture getSystemMetadata(String path) { throw new UnsupportedOperationException(); } + @Override public ListenableFuture getUserMetadata(String path) { if (path.indexOf('/') == -1) throw new UnsupportedOperationException(); @@ -168,6 +174,7 @@ public class StubAtmosAsyncClient implements AtmosAsyncClient { } } + @Override public ListenableFuture headFile(String path) { String container = path.substring(0, path.indexOf('/')); path = path.substring(path.indexOf('/') + 1); @@ -178,12 +185,14 @@ public class StubAtmosAsyncClient implements AtmosAsyncClient { } } + @Override public ListenableFuture> listDirectories(ListOptions... optionsList) { // org.jclouds.blobstore.options.ListOptions options = container2ContainerListOptions // .apply(optionsList); return Futures.compose(blobStore.list(), resource2ObjectList, service); } + @Override public ListenableFuture> listDirectory(String directoryName, ListOptions... optionsList) { org.jclouds.blobstore.options.ListContainerOptions options = container2ContainerListOptions.apply(optionsList); @@ -197,10 +206,12 @@ public class StubAtmosAsyncClient implements AtmosAsyncClient { return Futures.compose(blobStore.list(container, options), resource2ObjectList, service); } + @Override public AtmosObject newObject() { return this.objectProvider.create(null); } + @Override public ListenableFuture pathExists(final String path) { if (path.indexOf('/') == path.length() - 1) { // chop off the trailing slash @@ -218,6 +229,7 @@ public class StubAtmosAsyncClient implements AtmosAsyncClient { } } + @Override public ListenableFuture readFile(String path, GetOptions... options) { String container = path.substring(0, path.indexOf('/')); String blobName = path.substring(path.indexOf('/') + 1); @@ -225,7 +237,13 @@ public class StubAtmosAsyncClient implements AtmosAsyncClient { return Futures.compose(blobStore.getBlob(container, blobName, getOptions), blob2Object, service); } - public ListenableFuture updateFile(String parent, AtmosObject object) { + @Override + public ListenableFuture updateFile(String parent, AtmosObject object, PutOptions... options) { + throw new UnsupportedOperationException(); + } + + @Override + public ListenableFuture isPublic(String path) { throw new UnsupportedOperationException(); } diff --git a/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseContainerLiveTest.java b/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseContainerLiveTest.java index a0975d6c67..fb3c35f6a9 100644 --- a/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseContainerLiveTest.java +++ b/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseContainerLiveTest.java @@ -47,7 +47,9 @@ public class BaseContainerLiveTest extends BaseBlobStoreIntegrationTest { BlobMetadata metadata = context.getBlobStore().blobMetadata(containerName, "hello"); - assertEquals(Strings2.toStringAndClose(metadata.getPublicUri().toURL().openStream()), TEST_STRING); + assert metadata.getPublicUri() != null : metadata; + + assertEquals(Strings2.toStringAndClose(context.utils().http().get(metadata.getPublicUri())), TEST_STRING); } finally { // this container is now public, so we can't reuse it directly From ce13a863a9828091e9a0a8a37f47bb34c108369c Mon Sep 17 00:00:00 2001 From: Adrian Cole Date: Fri, 3 Jun 2011 02:35:12 -0700 Subject: [PATCH 056/264] Issue 550: added PM for cloudsigma --- .../CloudSigmaZurichProviderMetadata.java | 115 ++++++++++++++++++ .../org.jclouds.providers.ProviderMetadata | 1 + .../CloudSigmaZurichProviderTest.java | 35 ++++++ 3 files changed, 151 insertions(+) create mode 100644 providers/cloudsigma-zrh/src/main/java/org/jclouds/cloudsigma/CloudSigmaZurichProviderMetadata.java create mode 100644 providers/cloudsigma-zrh/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata create mode 100644 providers/cloudsigma-zrh/src/test/java/org/jclouds/cloudsigma/CloudSigmaZurichProviderTest.java diff --git a/providers/cloudsigma-zrh/src/main/java/org/jclouds/cloudsigma/CloudSigmaZurichProviderMetadata.java b/providers/cloudsigma-zrh/src/main/java/org/jclouds/cloudsigma/CloudSigmaZurichProviderMetadata.java new file mode 100644 index 0000000000..30b78b9fc2 --- /dev/null +++ b/providers/cloudsigma-zrh/src/main/java/org/jclouds/cloudsigma/CloudSigmaZurichProviderMetadata.java @@ -0,0 +1,115 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.jclouds.cloudsigma; + +import com.google.common.collect.ImmutableSet; + +import java.net.URI; +import java.util.Set; + +import org.jclouds.providers.BaseProviderMetadata; +import org.jclouds.providers.ProviderMetadata; + +/** + * Implementation of {@link org.jclouds.types.ProviderMetadata} for CloudSigma Zurich. + * + * @author Adrian Cole + */ +public class CloudSigmaZurichProviderMetadata extends BaseProviderMetadata { + + /** + * {@inheritDoc} + */ + @Override + public String getId() { + return "cloudsigma-zrh"; + } + + /** + * {@inheritDoc} + */ + @Override + public String getType() { + return ProviderMetadata.COMPUTE_TYPE; + } + + /** + * {@inheritDoc} + */ + @Override + public String getName() { + return "CloudSigma Zurich"; + } + + /** + * {@inheritDoc} + */ + @Override + public String getIdentityName() { + return "Email"; + } + + /** + * {@inheritDoc} + */ + @Override + public String getCredentialName() { + return "Password"; + } + + /** + * {@inheritDoc} + */ + @Override + public URI getHomepage() { + return URI.create("http://www.cloudsigma.com/en/our-cloud/features"); + } + + /** + * {@inheritDoc} + */ + @Override + public URI getConsole() { + return URI.create("https://cs.cloudsigma.com/"); + } + /** + * {@inheritDoc} + */ + @Override + public URI getApiDocumentation() { + return URI.create("http://cloudsigma.com/en/platform-details/the-api"); + } + + /** + * {@inheritDoc} + */ + @Override + public Set getLinkedServices() { + return ImmutableSet.of("cloudsigma-zrh"); + } + + /** + * {@inheritDoc} + */ + @Override + public Set getIso3166Codes() { + return ImmutableSet.of("CH-ZH"); + } + +} diff --git a/providers/cloudsigma-zrh/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata b/providers/cloudsigma-zrh/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata new file mode 100644 index 0000000000..8a1ef553b4 --- /dev/null +++ b/providers/cloudsigma-zrh/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata @@ -0,0 +1 @@ +org.jclouds.cloudsigma.CloudSigmaZurichProviderMetadata diff --git a/providers/cloudsigma-zrh/src/test/java/org/jclouds/cloudsigma/CloudSigmaZurichProviderTest.java b/providers/cloudsigma-zrh/src/test/java/org/jclouds/cloudsigma/CloudSigmaZurichProviderTest.java new file mode 100644 index 0000000000..4f1534e47d --- /dev/null +++ b/providers/cloudsigma-zrh/src/test/java/org/jclouds/cloudsigma/CloudSigmaZurichProviderTest.java @@ -0,0 +1,35 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.jclouds.cloudsigma; + +import org.jclouds.providers.BaseProviderMetadataTest; +import org.jclouds.providers.ProviderMetadata; +import org.testng.annotations.Test; + +/** + * + * @author Adrian Cole + */ +@Test(groups = "unit", testName = "CloudSigmaZurichProviderTest") +public class CloudSigmaZurichProviderTest extends BaseProviderMetadataTest { + + public CloudSigmaZurichProviderTest() { + super(new CloudSigmaZurichProviderMetadata(), ProviderMetadata.COMPUTE_TYPE); + } +} From 3028a05fa865a6e2cfd3e9ee6378fbf50c70801a Mon Sep 17 00:00:00 2001 From: Andrew Phillips Date: Fri, 3 Jun 2011 14:23:33 +0200 Subject: [PATCH 057/264] ${version}.${tweetstore.instance} -> ${version}-${tweetstore.instance} for jclouds.properties remote resource version as it's closer to using a classifier (not supported by the plugin) --- demos/tweetstore/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/demos/tweetstore/pom.xml b/demos/tweetstore/pom.xml index 2b9bb2dda9..114e7d2955 100644 --- a/demos/tweetstore/pom.xml +++ b/demos/tweetstore/pom.xml @@ -169,7 +169,7 @@ - ${project.groupId}:jclouds-demos-tweetstore-jclouds-properties:${project.version}.${tweetstore.instance} + ${project.groupId}:jclouds-demos-tweetstore-jclouds-properties:${project.version}-${tweetstore.instance} From 6207fab3b2109821d752c40a2eb73fa077fd0c99 Mon Sep 17 00:00:00 2001 From: Adrian Cole Date: Sat, 4 Jun 2011 22:47:01 -0700 Subject: [PATCH 058/264] updated to jclouds 1.0.0 --- README.txt | 40 ++++++++++++++++++++++++---------------- 1 file changed, 24 insertions(+), 16 deletions(-) diff --git a/README.txt b/README.txt index ff09b7f225..b5b01bccf3 100644 --- a/README.txt +++ b/README.txt @@ -26,7 +26,7 @@ two abstractions at the moment: compute and blobstore. compute helps you bootstrap machines in the cloud. blobstore helps you manage key-value data. -our current version is 1.0-beta-9c +our current version is 1.0.0 our dev version is 1.0-SNAPSHOT our compute api supports: aws-ec2, gogrid, cloudservers-us, stub (in-memory), deltacloud, @@ -75,16 +75,15 @@ BlobStore Example (Java): blobStore.createContainerInLocation(null, "mycontainer"); // add blob - blob = blobStore.newBlob("test"); - blob.setPayload("testdata"); + blob = blobStore.blobBuilder("test").payload("testdata").build(); blobStore.putBlob("mycontainer", blob); BlobStore Example (Clojure): - (use 'org.jclouds.blobstore) + (use 'org.jclouds.blobstore2) - (with-blobstore ["azureblob" account encodedkey] - (create-container "mycontainer") - (upload-blob "mycontainer" "test" "testdata")) + (def *blobstore* (blobstore "azureblob" account encodedkey)) + (create-container *blobstore* "mycontainer") + (put-blob *blobstore* "mycontainer" (blob "test" :payload "testdata")) Compute Example (Java): // init @@ -98,31 +97,40 @@ Compute Example (Java): // define the requirements of your node template = client.templateBuilder().osFamily(UBUNTU).smallest().build(); + + // setup a boot user which is the same as your login + template.getOptions().runScript(AdminAccess.standard()); // these nodes will be accessible via ssh when the call returns nodes = client.createNodesInGroup("mycluster", 2, template); + // you can now run ad-hoc commands on the nodes based on predicates + responses = client.runScriptOnNodesMatching(inGroup("mycluster"), "uptime", + wrapInInitScript(false)); + Compute Example (Clojure): - (use 'org.jclouds.compute) + (use 'org.jclouds.compute2) ; create a compute service using ssh and log4j extensions (def compute - (compute-service "trmk`-ecloud" "user" "password" :ssh :log4j)) + (*compute* "trmk`-ecloud" "user" "password" :ssh :log4j)) - ; use the default node template and launch a couple nodes - ; these will have your ~/.ssh/id_rsa.pub authorized when complete - (with-compute-service [compute] - (create-nodes "mycluster" 2)) + ; launch a couple nodes with the default operating system, installing your user. + (create-nodes *compute* "mycluster" 2 + (TemplateOptions$Builder/runScript (AdminAccess/standard))) + ; run a command on that group + (run-script-on-nodes-matching *compute* (in-group? "mycluster") "uptime" + (RunScriptOptions$Builder/wrapInInitScript false)) + Downloads: - * distribution zip: http://jclouds.googlecode.com/files/jclouds-1.0-beta-9c.zip + * installation guide: http://code.google.com/p/jclouds/wiki/Installation * maven repo: http://repo2.maven.org/maven2 (maven central - the default repository) * snapshot repo: https://oss.sonatype.org/content/repositories/snapshots Links: * project page: http://code.google.com/p/jclouds/ - * javadocs (1.0-beta-9c): http://jclouds.rimuhosting.com/apidocs/ - * javadocs (1.0-SNAPSHOT): http://jclouds.rimuhosting.com/apidocs-SNAPSHOT/ + * javadocs: http://jclouds.rimuhosting.com/apidocs/ * community: http://code.google.com/p/jclouds/wiki/AppsThatUseJClouds * user group: http://groups.google.com/group/jclouds * dev group: http://groups.google.com/group/jclouds-dev From f391aff38efbf3bd87849e854c698854cc28434e Mon Sep 17 00:00:00 2001 From: Adrian Cole Date: Sat, 4 Jun 2011 22:49:24 -0700 Subject: [PATCH 059/264] added link to examples --- README.txt | 21 ++------------------- 1 file changed, 2 insertions(+), 19 deletions(-) diff --git a/README.txt b/README.txt index b5b01bccf3..fef2aa95f4 100644 --- a/README.txt +++ b/README.txt @@ -1,22 +1,3 @@ -==== - - Copyright (C) 2011 Cloud Conscious, LLC. - - ==================================================================== - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - ==================================================================== -==== - Overview: jclouds is an open source library that helps you get started in the cloud @@ -29,6 +10,8 @@ data. our current version is 1.0.0 our dev version is 1.0-SNAPSHOT +check out our examples site! https://github.com/jclouds/jclouds-examples + our compute api supports: aws-ec2, gogrid, cloudservers-us, stub (in-memory), deltacloud, cloudservers-uk, vcloud (generic), ec2 (generic), byon, nova, trmk-ecloud, trmk-vcloudexpress, eucalyptus (generic), From 7d2fb23119aee6222148443c08520de4d29613d9 Mon Sep 17 00:00:00 2001 From: Andrew Phillips Date: Sun, 5 Jun 2011 11:17:43 +0400 Subject: [PATCH 060/264] Master version is now 1.1.0-SNAPSHOT (= next feature version) now that 1.0.0 is out --- all/pom.xml | 2 +- allblobstore/pom.xml | 2 +- allcompute/pom.xml | 2 +- allloadbalancer/pom.xml | 2 +- antcontrib/pom.xml | 7 +++---- apis/atmos/pom.xml | 2 +- apis/byon/pom.xml | 5 ++--- apis/cloudfiles/pom.xml | 5 ++--- apis/cloudservers/pom.xml | 5 ++--- apis/deltacloud/pom.xml | 2 +- apis/ec2/pom.xml | 5 ++--- apis/elasticstack/pom.xml | 2 +- apis/eucalyptus/pom.xml | 5 ++--- apis/filesystem/pom.xml | 5 ++--- apis/nova/pom.xml | 5 ++--- apis/pom.xml | 2 +- apis/s3/pom.xml | 5 ++--- apis/swift/pom.xml | 5 ++--- apis/vcloud/pom.xml | 5 ++--- apis/vcloudexpress/pom.xml | 5 ++--- apis/walrus/pom.xml | 5 ++--- archetypes/compute-service-archetype/pom.xml | 5 ++--- archetypes/pom.xml | 2 +- archetypes/rest-client-archetype/pom.xml | 5 ++--- assemblies/pom.xml | 2 +- blobstore/pom.xml | 5 ++--- common/aws/pom.xml | 2 +- common/azure/pom.xml | 2 +- common/openstack/pom.xml | 2 +- common/pom.xml | 2 +- common/trmk/pom.xml | 2 +- common/vcloud/pom.xml | 2 +- compute/pom.xml | 5 ++--- core/pom.xml | 5 ++--- drivers/apachehc/pom.xml | 5 ++--- drivers/bouncycastle/pom.xml | 5 ++--- drivers/enterprise/pom.xml | 5 ++--- drivers/gae/pom.xml | 5 ++--- drivers/joda/pom.xml | 5 ++--- drivers/jsch/pom.xml | 5 ++--- drivers/log4j/pom.xml | 5 ++--- drivers/netty/pom.xml | 5 ++--- drivers/pom.xml | 2 +- drivers/slf4j/pom.xml | 5 ++--- loadbalancer/pom.xml | 5 ++--- pom.xml | 2 +- project/pom.xml | 2 +- providers/aws-ec2/pom.xml | 5 ++--- providers/aws-s3/pom.xml | 5 ++--- providers/azureblob/pom.xml | 5 ++--- providers/bluelock-vcdirector/pom.xml | 5 ++--- providers/bluelock-vcloud-vcenterprise/pom.xml | 5 ++--- providers/bluelock-vcloud-zone01/pom.xml | 5 ++--- providers/cloudfiles-uk/pom.xml | 5 ++--- providers/cloudfiles-us/pom.xml | 5 ++--- providers/cloudloadbalancers-us/pom.xml | 2 +- providers/cloudonestorage/pom.xml | 5 ++--- providers/cloudservers-uk/pom.xml | 5 ++--- providers/cloudservers-us/pom.xml | 5 ++--- providers/cloudsigma-zrh/pom.xml | 2 +- providers/elastichosts-lon-b/pom.xml | 5 ++--- providers/elastichosts-lon-p/pom.xml | 5 ++--- providers/elastichosts-sat-p/pom.xml | 5 ++--- providers/eucalyptus-partnercloud-ec2/pom.xml | 5 ++--- providers/eucalyptus-partnercloud-s3/pom.xml | 5 ++--- providers/gogrid/pom.xml | 5 ++--- providers/ninefold-storage/pom.xml | 5 ++--- providers/openhosting-east1/pom.xml | 5 ++--- providers/pom.xml | 2 +- providers/rimuhosting/pom.xml | 5 ++--- providers/savvis-symphonyvpdc/pom.xml | 2 +- providers/serverlove-z1-man/pom.xml | 5 ++--- providers/skalicloud-sdg-my/pom.xml | 5 ++--- providers/slicehost/pom.xml | 5 ++--- providers/stratogen-vcloud-mycloud/pom.xml | 5 ++--- providers/synaptic-storage/pom.xml | 5 ++--- providers/trmk-ecloud/pom.xml | 5 ++--- providers/trmk-vcloudexpress/pom.xml | 5 ++--- resources/pom.xml | 2 +- scriptbuilder/pom.xml | 7 +++---- skeletons/pom.xml | 2 +- skeletons/standalone-compute/pom.xml | 5 ++--- 82 files changed, 141 insertions(+), 198 deletions(-) diff --git a/all/pom.xml b/all/pom.xml index 6b3864bffc..4a6e186cb4 100644 --- a/all/pom.xml +++ b/all/pom.xml @@ -23,7 +23,7 @@ org.jclouds jclouds-project - 1.0-SNAPSHOT + 1.1.0-SNAPSHOT ../project/pom.xml jclouds-all diff --git a/allblobstore/pom.xml b/allblobstore/pom.xml index ac0bfbf517..c06678ffb9 100644 --- a/allblobstore/pom.xml +++ b/allblobstore/pom.xml @@ -23,7 +23,7 @@ org.jclouds jclouds-project - 1.0-SNAPSHOT + 1.1.0-SNAPSHOT ../project/pom.xml jclouds-allblobstore diff --git a/allcompute/pom.xml b/allcompute/pom.xml index c032904840..e4d0141f12 100644 --- a/allcompute/pom.xml +++ b/allcompute/pom.xml @@ -23,7 +23,7 @@ org.jclouds jclouds-project - 1.0-SNAPSHOT + 1.1.0-SNAPSHOT ../project/pom.xml jclouds-allcompute diff --git a/allloadbalancer/pom.xml b/allloadbalancer/pom.xml index 895cba5f32..1466a320ca 100644 --- a/allloadbalancer/pom.xml +++ b/allloadbalancer/pom.xml @@ -23,7 +23,7 @@ org.jclouds jclouds-project - 1.0-SNAPSHOT + 1.1.0-SNAPSHOT ../project/pom.xml jclouds-allloadbalancer diff --git a/antcontrib/pom.xml b/antcontrib/pom.xml index e1e370a878..f3ecf9e238 100644 --- a/antcontrib/pom.xml +++ b/antcontrib/pom.xml @@ -19,19 +19,18 @@ ==================================================================== --> - + 4.0.0 org.jclouds jclouds-project - 1.0-SNAPSHOT + 1.1.0-SNAPSHOT ../project/pom.xml jclouds-antcontrib Ant-Contrib extensions - + diff --git a/apis/atmos/pom.xml b/apis/atmos/pom.xml index d55db0e29e..f97dfc73cb 100644 --- a/apis/atmos/pom.xml +++ b/apis/atmos/pom.xml @@ -25,7 +25,7 @@ org.jclouds jclouds-project - 1.0-SNAPSHOT + 1.1.0-SNAPSHOT ../../project/pom.xml diff --git a/apis/byon/pom.xml b/apis/byon/pom.xml index c1575a1737..ea13793ee1 100644 --- a/apis/byon/pom.xml +++ b/apis/byon/pom.xml @@ -19,13 +19,12 @@ ==================================================================== --> - + 4.0.0 org.jclouds jclouds-project - 1.0-SNAPSHOT + 1.1.0-SNAPSHOT ../../project/pom.xml diff --git a/apis/cloudfiles/pom.xml b/apis/cloudfiles/pom.xml index e968b8dd5d..182d2830ef 100644 --- a/apis/cloudfiles/pom.xml +++ b/apis/cloudfiles/pom.xml @@ -20,13 +20,12 @@ --> - + 4.0.0 org.jclouds jclouds-project - 1.0-SNAPSHOT + 1.1.0-SNAPSHOT ../../project/pom.xml org.jclouds.api diff --git a/apis/cloudservers/pom.xml b/apis/cloudservers/pom.xml index 1b697e2594..83de0d1fde 100644 --- a/apis/cloudservers/pom.xml +++ b/apis/cloudservers/pom.xml @@ -20,13 +20,12 @@ --> - + 4.0.0 org.jclouds jclouds-project - 1.0-SNAPSHOT + 1.1.0-SNAPSHOT ../../project/pom.xml diff --git a/apis/deltacloud/pom.xml b/apis/deltacloud/pom.xml index 770e4a3776..c7353eec17 100644 --- a/apis/deltacloud/pom.xml +++ b/apis/deltacloud/pom.xml @@ -27,7 +27,7 @@ org.jclouds jclouds-project - 1.0-SNAPSHOT + 1.1.0-SNAPSHOT ../../project/pom.xml org.jclouds.api diff --git a/apis/ec2/pom.xml b/apis/ec2/pom.xml index c7f44d4125..e9ced2e714 100644 --- a/apis/ec2/pom.xml +++ b/apis/ec2/pom.xml @@ -20,13 +20,12 @@ --> - + 4.0.0 org.jclouds jclouds-project - 1.0-SNAPSHOT + 1.1.0-SNAPSHOT ../../project/pom.xml org.jclouds.api diff --git a/apis/elasticstack/pom.xml b/apis/elasticstack/pom.xml index 2ee5f9d36d..88542f4c96 100644 --- a/apis/elasticstack/pom.xml +++ b/apis/elasticstack/pom.xml @@ -27,7 +27,7 @@ org.jclouds jclouds-project - 1.0-SNAPSHOT + 1.1.0-SNAPSHOT ../../project/pom.xml org.jclouds.api diff --git a/apis/eucalyptus/pom.xml b/apis/eucalyptus/pom.xml index 9bc3d05365..07be116f29 100644 --- a/apis/eucalyptus/pom.xml +++ b/apis/eucalyptus/pom.xml @@ -20,13 +20,12 @@ --> - + 4.0.0 org.jclouds jclouds-project - 1.0-SNAPSHOT + 1.1.0-SNAPSHOT ../../project/pom.xml org.jclouds.api diff --git a/apis/filesystem/pom.xml b/apis/filesystem/pom.xml index a094f69d49..36c0539c88 100644 --- a/apis/filesystem/pom.xml +++ b/apis/filesystem/pom.xml @@ -20,13 +20,12 @@ --> - + 4.0.0 org.jclouds jclouds-project - 1.0-SNAPSHOT + 1.1.0-SNAPSHOT ../../project/pom.xml org.jclouds.api diff --git a/apis/nova/pom.xml b/apis/nova/pom.xml index f029512e81..6521c279b9 100644 --- a/apis/nova/pom.xml +++ b/apis/nova/pom.xml @@ -20,13 +20,12 @@ --> - + 4.0.0 org.jclouds jclouds-project - 1.0-SNAPSHOT + 1.1.0-SNAPSHOT ../../project/pom.xml org.jclouds.api diff --git a/apis/pom.xml b/apis/pom.xml index 42ecc2d880..f55bc2dd45 100644 --- a/apis/pom.xml +++ b/apis/pom.xml @@ -25,7 +25,7 @@ jclouds-project org.jclouds - 1.0-SNAPSHOT + 1.1.0-SNAPSHOT ../project/pom.xml org.jclouds.api diff --git a/apis/s3/pom.xml b/apis/s3/pom.xml index c5deb1bb9f..84b339d630 100644 --- a/apis/s3/pom.xml +++ b/apis/s3/pom.xml @@ -20,13 +20,12 @@ --> - + 4.0.0 org.jclouds jclouds-project - 1.0-SNAPSHOT + 1.1.0-SNAPSHOT ../../project/pom.xml org.jclouds.api diff --git a/apis/swift/pom.xml b/apis/swift/pom.xml index cc777879b4..f19eb59434 100644 --- a/apis/swift/pom.xml +++ b/apis/swift/pom.xml @@ -20,13 +20,12 @@ --> - + 4.0.0 org.jclouds jclouds-project - 1.0-SNAPSHOT + 1.1.0-SNAPSHOT ../../project/pom.xml org.jclouds.api diff --git a/apis/vcloud/pom.xml b/apis/vcloud/pom.xml index 1931c88099..12dda69a81 100644 --- a/apis/vcloud/pom.xml +++ b/apis/vcloud/pom.xml @@ -19,13 +19,12 @@ ==================================================================== --> - + 4.0.0 org.jclouds jclouds-project - 1.0-SNAPSHOT + 1.1.0-SNAPSHOT ../../project/pom.xml org.jclouds.api diff --git a/apis/vcloudexpress/pom.xml b/apis/vcloudexpress/pom.xml index 229cfdc70a..bc624aeee9 100644 --- a/apis/vcloudexpress/pom.xml +++ b/apis/vcloudexpress/pom.xml @@ -19,13 +19,12 @@ ==================================================================== --> - + 4.0.0 org.jclouds jclouds-project - 1.0-SNAPSHOT + 1.1.0-SNAPSHOT ../../project/pom.xml org.jclouds.api diff --git a/apis/walrus/pom.xml b/apis/walrus/pom.xml index 704060ddf8..602554e808 100644 --- a/apis/walrus/pom.xml +++ b/apis/walrus/pom.xml @@ -20,13 +20,12 @@ --> - + 4.0.0 org.jclouds jclouds-project - 1.0-SNAPSHOT + 1.1.0-SNAPSHOT ../../project/pom.xml org.jclouds.api diff --git a/archetypes/compute-service-archetype/pom.xml b/archetypes/compute-service-archetype/pom.xml index 1a532624d9..00a0ff2524 100644 --- a/archetypes/compute-service-archetype/pom.xml +++ b/archetypes/compute-service-archetype/pom.xml @@ -20,13 +20,12 @@ --> - + 4.0.0 org.jclouds jclouds-project - 1.0-SNAPSHOT + 1.1.0-SNAPSHOT ../../project/pom.xml jclouds-compute-service-archetype diff --git a/archetypes/pom.xml b/archetypes/pom.xml index b0fd181e10..1767a098bd 100644 --- a/archetypes/pom.xml +++ b/archetypes/pom.xml @@ -25,7 +25,7 @@ jclouds-project org.jclouds - 1.0-SNAPSHOT + 1.1.0-SNAPSHOT ../project/pom.xml jclouds-archetypes diff --git a/archetypes/rest-client-archetype/pom.xml b/archetypes/rest-client-archetype/pom.xml index f196efa967..be700a1e75 100644 --- a/archetypes/rest-client-archetype/pom.xml +++ b/archetypes/rest-client-archetype/pom.xml @@ -20,13 +20,12 @@ --> - + 4.0.0 org.jclouds jclouds-project - 1.0-SNAPSHOT + 1.1.0-SNAPSHOT ../../project/pom.xml jclouds-rest-client-archetype diff --git a/assemblies/pom.xml b/assemblies/pom.xml index 57d1e89cd2..3ad170a43a 100644 --- a/assemblies/pom.xml +++ b/assemblies/pom.xml @@ -25,7 +25,7 @@ jclouds-project org.jclouds - 1.0-SNAPSHOT + 1.1.0-SNAPSHOT ../project/pom.xml jclouds-assemblies diff --git a/blobstore/pom.xml b/blobstore/pom.xml index 1a80f77774..961f0eff72 100644 --- a/blobstore/pom.xml +++ b/blobstore/pom.xml @@ -20,13 +20,12 @@ --> - + 4.0.0 org.jclouds jclouds-project - 1.0-SNAPSHOT + 1.1.0-SNAPSHOT ../project/pom.xml jclouds-blobstore diff --git a/common/aws/pom.xml b/common/aws/pom.xml index dbddac8ce2..48b981f06a 100644 --- a/common/aws/pom.xml +++ b/common/aws/pom.xml @@ -25,7 +25,7 @@ org.jclouds jclouds-project - 1.0-SNAPSHOT + 1.1.0-SNAPSHOT ../../project/pom.xml org.jclouds.common diff --git a/common/azure/pom.xml b/common/azure/pom.xml index f0c9a62c2f..42b17d737e 100644 --- a/common/azure/pom.xml +++ b/common/azure/pom.xml @@ -25,7 +25,7 @@ org.jclouds jclouds-project - 1.0-SNAPSHOT + 1.1.0-SNAPSHOT ../../project/pom.xml org.jclouds.common diff --git a/common/openstack/pom.xml b/common/openstack/pom.xml index bb381bb985..2d45180f54 100644 --- a/common/openstack/pom.xml +++ b/common/openstack/pom.xml @@ -25,7 +25,7 @@ org.jclouds jclouds-project - 1.0-SNAPSHOT + 1.1.0-SNAPSHOT ../../project/pom.xml diff --git a/common/pom.xml b/common/pom.xml index c9f450948a..2c40e26894 100644 --- a/common/pom.xml +++ b/common/pom.xml @@ -25,7 +25,7 @@ jclouds-project org.jclouds - 1.0-SNAPSHOT + 1.1.0-SNAPSHOT ../project/pom.xml org.jclouds.common diff --git a/common/trmk/pom.xml b/common/trmk/pom.xml index 589cd9d728..9335fd308a 100644 --- a/common/trmk/pom.xml +++ b/common/trmk/pom.xml @@ -25,7 +25,7 @@ org.jclouds jclouds-project - 1.0-SNAPSHOT + 1.1.0-SNAPSHOT ../../project/pom.xml diff --git a/common/vcloud/pom.xml b/common/vcloud/pom.xml index b1e1f811e8..0ca8538ddf 100644 --- a/common/vcloud/pom.xml +++ b/common/vcloud/pom.xml @@ -25,7 +25,7 @@ org.jclouds jclouds-project - 1.0-SNAPSHOT + 1.1.0-SNAPSHOT ../../project/pom.xml diff --git a/compute/pom.xml b/compute/pom.xml index 0cba258a7b..738686dd86 100644 --- a/compute/pom.xml +++ b/compute/pom.xml @@ -20,13 +20,12 @@ --> - + 4.0.0 org.jclouds jclouds-project - 1.0-SNAPSHOT + 1.1.0-SNAPSHOT ../project/pom.xml diff --git a/core/pom.xml b/core/pom.xml index 5a724a7ff8..1988c451d5 100644 --- a/core/pom.xml +++ b/core/pom.xml @@ -19,13 +19,12 @@ ==================================================================== --> - + 4.0.0 jclouds-project org.jclouds - 1.0-SNAPSHOT + 1.1.0-SNAPSHOT ../project/pom.xml jclouds-core diff --git a/drivers/apachehc/pom.xml b/drivers/apachehc/pom.xml index 230050a0c4..d6edcf62e6 100644 --- a/drivers/apachehc/pom.xml +++ b/drivers/apachehc/pom.xml @@ -20,13 +20,12 @@ --> - + 4.0.0 org.jclouds jclouds-project - 1.0-SNAPSHOT + 1.1.0-SNAPSHOT ../../project/pom.xml org.jclouds.driver diff --git a/drivers/bouncycastle/pom.xml b/drivers/bouncycastle/pom.xml index e04f55fc33..090875f51c 100644 --- a/drivers/bouncycastle/pom.xml +++ b/drivers/bouncycastle/pom.xml @@ -20,13 +20,12 @@ --> - + 4.0.0 org.jclouds jclouds-project - 1.0-SNAPSHOT + 1.1.0-SNAPSHOT ../../project/pom.xml org.jclouds.driver diff --git a/drivers/enterprise/pom.xml b/drivers/enterprise/pom.xml index c615581773..c5cba243bb 100644 --- a/drivers/enterprise/pom.xml +++ b/drivers/enterprise/pom.xml @@ -20,13 +20,12 @@ --> - + 4.0.0 org.jclouds jclouds-project - 1.0-SNAPSHOT + 1.1.0-SNAPSHOT ../../project/pom.xml org.jclouds.driver diff --git a/drivers/gae/pom.xml b/drivers/gae/pom.xml index c0def2b73e..2a54d87b8b 100644 --- a/drivers/gae/pom.xml +++ b/drivers/gae/pom.xml @@ -18,13 +18,12 @@ ==================================================================== --> - + 4.0.0 org.jclouds jclouds-project - 1.0-SNAPSHOT + 1.1.0-SNAPSHOT ../../project/pom.xml org.jclouds.driver diff --git a/drivers/joda/pom.xml b/drivers/joda/pom.xml index f188822bcf..f93c2bbd0a 100644 --- a/drivers/joda/pom.xml +++ b/drivers/joda/pom.xml @@ -20,13 +20,12 @@ --> - + 4.0.0 org.jclouds jclouds-project - 1.0-SNAPSHOT + 1.1.0-SNAPSHOT ../../project/pom.xml org.jclouds.driver diff --git a/drivers/jsch/pom.xml b/drivers/jsch/pom.xml index 7b74008307..df1314fcad 100644 --- a/drivers/jsch/pom.xml +++ b/drivers/jsch/pom.xml @@ -20,13 +20,12 @@ --> - + 4.0.0 org.jclouds jclouds-project - 1.0-SNAPSHOT + 1.1.0-SNAPSHOT ../../project/pom.xml org.jclouds.driver diff --git a/drivers/log4j/pom.xml b/drivers/log4j/pom.xml index 17cfdcbb6e..49c59f290b 100644 --- a/drivers/log4j/pom.xml +++ b/drivers/log4j/pom.xml @@ -20,13 +20,12 @@ --> - + 4.0.0 org.jclouds jclouds-project - 1.0-SNAPSHOT + 1.1.0-SNAPSHOT ../../project/pom.xml org.jclouds.driver diff --git a/drivers/netty/pom.xml b/drivers/netty/pom.xml index 77c9717183..41d1b0598b 100644 --- a/drivers/netty/pom.xml +++ b/drivers/netty/pom.xml @@ -20,13 +20,12 @@ --> - + 4.0.0 org.jclouds jclouds-project - 1.0-SNAPSHOT + 1.1.0-SNAPSHOT ../../project/pom.xml org.jclouds.driver diff --git a/drivers/pom.xml b/drivers/pom.xml index a624a8ceb6..ac3ae2a421 100644 --- a/drivers/pom.xml +++ b/drivers/pom.xml @@ -25,7 +25,7 @@ jclouds-project org.jclouds - 1.0-SNAPSHOT + 1.1.0-SNAPSHOT ../project/pom.xml jclouds-drivers-project diff --git a/drivers/slf4j/pom.xml b/drivers/slf4j/pom.xml index 6d0760c45d..7513cd0211 100644 --- a/drivers/slf4j/pom.xml +++ b/drivers/slf4j/pom.xml @@ -20,13 +20,12 @@ --> - + 4.0.0 org.jclouds jclouds-project - 1.0-SNAPSHOT + 1.1.0-SNAPSHOT ../../project/pom.xml org.jclouds.driver diff --git a/loadbalancer/pom.xml b/loadbalancer/pom.xml index 7fd66622ea..32d6dd3de6 100644 --- a/loadbalancer/pom.xml +++ b/loadbalancer/pom.xml @@ -20,13 +20,12 @@ --> - + 4.0.0 org.jclouds jclouds-project - 1.0-SNAPSHOT + 1.1.0-SNAPSHOT ../project/pom.xml jclouds-loadbalancer diff --git a/pom.xml b/pom.xml index a4061982d2..c0287ffc33 100644 --- a/pom.xml +++ b/pom.xml @@ -24,7 +24,7 @@ org.jclouds jclouds-project - 1.0-SNAPSHOT + 1.1.0-SNAPSHOT project/pom.xml jclouds-multi diff --git a/project/pom.xml b/project/pom.xml index 111c785f7f..101dd59cb9 100644 --- a/project/pom.xml +++ b/project/pom.xml @@ -29,7 +29,7 @@ org.jclouds jclouds-project - 1.0-SNAPSHOT + 1.1.0-SNAPSHOT pom jclouds Project http://www.jclouds.org diff --git a/providers/aws-ec2/pom.xml b/providers/aws-ec2/pom.xml index 8634072915..cfa2c564f1 100644 --- a/providers/aws-ec2/pom.xml +++ b/providers/aws-ec2/pom.xml @@ -20,13 +20,12 @@ --> - + 4.0.0 org.jclouds jclouds-project - 1.0-SNAPSHOT + 1.1.0-SNAPSHOT ../../project/pom.xml org.jclouds.provider diff --git a/providers/aws-s3/pom.xml b/providers/aws-s3/pom.xml index 393033ac10..74a91cfa24 100644 --- a/providers/aws-s3/pom.xml +++ b/providers/aws-s3/pom.xml @@ -20,13 +20,12 @@ --> - + 4.0.0 org.jclouds jclouds-project - 1.0-SNAPSHOT + 1.1.0-SNAPSHOT ../../project/pom.xml org.jclouds.provider diff --git a/providers/azureblob/pom.xml b/providers/azureblob/pom.xml index 4d5389cfb7..dc7317f20e 100644 --- a/providers/azureblob/pom.xml +++ b/providers/azureblob/pom.xml @@ -20,13 +20,12 @@ --> - + 4.0.0 org.jclouds jclouds-project - 1.0-SNAPSHOT + 1.1.0-SNAPSHOT ../../project/pom.xml org.jclouds.provider diff --git a/providers/bluelock-vcdirector/pom.xml b/providers/bluelock-vcdirector/pom.xml index 648c9d57a0..32d3938e95 100644 --- a/providers/bluelock-vcdirector/pom.xml +++ b/providers/bluelock-vcdirector/pom.xml @@ -20,13 +20,12 @@ --> - + 4.0.0 org.jclouds jclouds-project - 1.0-SNAPSHOT + 1.1.0-SNAPSHOT ../../project/pom.xml org.jclouds.provider diff --git a/providers/bluelock-vcloud-vcenterprise/pom.xml b/providers/bluelock-vcloud-vcenterprise/pom.xml index ef0a7d2ca7..ca1d0e83dd 100644 --- a/providers/bluelock-vcloud-vcenterprise/pom.xml +++ b/providers/bluelock-vcloud-vcenterprise/pom.xml @@ -20,13 +20,12 @@ --> - + 4.0.0 org.jclouds jclouds-project - 1.0-SNAPSHOT + 1.1.0-SNAPSHOT ../../project/pom.xml org.jclouds.provider diff --git a/providers/bluelock-vcloud-zone01/pom.xml b/providers/bluelock-vcloud-zone01/pom.xml index ace6570bb2..1d2e178b78 100644 --- a/providers/bluelock-vcloud-zone01/pom.xml +++ b/providers/bluelock-vcloud-zone01/pom.xml @@ -20,13 +20,12 @@ --> - + 4.0.0 org.jclouds jclouds-project - 1.0-SNAPSHOT + 1.1.0-SNAPSHOT ../../project/pom.xml org.jclouds.provider diff --git a/providers/cloudfiles-uk/pom.xml b/providers/cloudfiles-uk/pom.xml index cb512c9597..fe9c44b571 100644 --- a/providers/cloudfiles-uk/pom.xml +++ b/providers/cloudfiles-uk/pom.xml @@ -20,13 +20,12 @@ --> - + 4.0.0 org.jclouds jclouds-project - 1.0-SNAPSHOT + 1.1.0-SNAPSHOT ../../project/pom.xml org.jclouds.provider diff --git a/providers/cloudfiles-us/pom.xml b/providers/cloudfiles-us/pom.xml index f0457f37db..09a28cc040 100644 --- a/providers/cloudfiles-us/pom.xml +++ b/providers/cloudfiles-us/pom.xml @@ -20,13 +20,12 @@ --> - + 4.0.0 org.jclouds jclouds-project - 1.0-SNAPSHOT + 1.1.0-SNAPSHOT ../../project/pom.xml org.jclouds.provider diff --git a/providers/cloudloadbalancers-us/pom.xml b/providers/cloudloadbalancers-us/pom.xml index 1cca29a863..e723b2fd31 100644 --- a/providers/cloudloadbalancers-us/pom.xml +++ b/providers/cloudloadbalancers-us/pom.xml @@ -27,7 +27,7 @@ org.jclouds jclouds-project - 1.0-SNAPSHOT + 1.1.0-SNAPSHOT ../../project/pom.xml org.jclouds.provider diff --git a/providers/cloudonestorage/pom.xml b/providers/cloudonestorage/pom.xml index faf627d65f..ef94a92c7d 100644 --- a/providers/cloudonestorage/pom.xml +++ b/providers/cloudonestorage/pom.xml @@ -20,13 +20,12 @@ --> - + 4.0.0 org.jclouds jclouds-project - 1.0-SNAPSHOT + 1.1.0-SNAPSHOT ../../project/pom.xml org.jclouds.provider diff --git a/providers/cloudservers-uk/pom.xml b/providers/cloudservers-uk/pom.xml index cf661a8faf..aacae5b086 100644 --- a/providers/cloudservers-uk/pom.xml +++ b/providers/cloudservers-uk/pom.xml @@ -20,13 +20,12 @@ --> - + 4.0.0 org.jclouds jclouds-project - 1.0-SNAPSHOT + 1.1.0-SNAPSHOT ../../project/pom.xml org.jclouds.provider diff --git a/providers/cloudservers-us/pom.xml b/providers/cloudservers-us/pom.xml index 19ac0bf45f..3ead858b01 100644 --- a/providers/cloudservers-us/pom.xml +++ b/providers/cloudservers-us/pom.xml @@ -20,13 +20,12 @@ --> - + 4.0.0 org.jclouds jclouds-project - 1.0-SNAPSHOT + 1.1.0-SNAPSHOT ../../project/pom.xml org.jclouds.provider diff --git a/providers/cloudsigma-zrh/pom.xml b/providers/cloudsigma-zrh/pom.xml index c73e1220f7..1615ca2102 100644 --- a/providers/cloudsigma-zrh/pom.xml +++ b/providers/cloudsigma-zrh/pom.xml @@ -27,7 +27,7 @@ org.jclouds jclouds-project - 1.0-SNAPSHOT + 1.1.0-SNAPSHOT ../../project/pom.xml org.jclouds.provider diff --git a/providers/elastichosts-lon-b/pom.xml b/providers/elastichosts-lon-b/pom.xml index a9cacc91be..6246f98bc5 100644 --- a/providers/elastichosts-lon-b/pom.xml +++ b/providers/elastichosts-lon-b/pom.xml @@ -20,13 +20,12 @@ --> - + 4.0.0 org.jclouds jclouds-project - 1.0-SNAPSHOT + 1.1.0-SNAPSHOT ../../project/pom.xml org.jclouds.provider diff --git a/providers/elastichosts-lon-p/pom.xml b/providers/elastichosts-lon-p/pom.xml index b6428a30d2..790c050f0c 100644 --- a/providers/elastichosts-lon-p/pom.xml +++ b/providers/elastichosts-lon-p/pom.xml @@ -20,13 +20,12 @@ --> - + 4.0.0 org.jclouds jclouds-project - 1.0-SNAPSHOT + 1.1.0-SNAPSHOT ../../project/pom.xml org.jclouds.provider diff --git a/providers/elastichosts-sat-p/pom.xml b/providers/elastichosts-sat-p/pom.xml index 9d033963d1..6ede37a6bb 100644 --- a/providers/elastichosts-sat-p/pom.xml +++ b/providers/elastichosts-sat-p/pom.xml @@ -20,13 +20,12 @@ --> - + 4.0.0 org.jclouds jclouds-project - 1.0-SNAPSHOT + 1.1.0-SNAPSHOT ../../project/pom.xml org.jclouds.provider diff --git a/providers/eucalyptus-partnercloud-ec2/pom.xml b/providers/eucalyptus-partnercloud-ec2/pom.xml index 10f626e397..115c2caab5 100644 --- a/providers/eucalyptus-partnercloud-ec2/pom.xml +++ b/providers/eucalyptus-partnercloud-ec2/pom.xml @@ -20,13 +20,12 @@ --> - + 4.0.0 org.jclouds jclouds-project - 1.0-SNAPSHOT + 1.1.0-SNAPSHOT ../../project/pom.xml org.jclouds.provider diff --git a/providers/eucalyptus-partnercloud-s3/pom.xml b/providers/eucalyptus-partnercloud-s3/pom.xml index b21814f6d9..daa1949366 100644 --- a/providers/eucalyptus-partnercloud-s3/pom.xml +++ b/providers/eucalyptus-partnercloud-s3/pom.xml @@ -20,13 +20,12 @@ --> - + 4.0.0 org.jclouds jclouds-project - 1.0-SNAPSHOT + 1.1.0-SNAPSHOT ../../project/pom.xml org.jclouds.provider diff --git a/providers/gogrid/pom.xml b/providers/gogrid/pom.xml index cb335d0d07..88120d148a 100644 --- a/providers/gogrid/pom.xml +++ b/providers/gogrid/pom.xml @@ -20,13 +20,12 @@ and limitations under the License. ==================================================================== --> - + 4.0.0 org.jclouds jclouds-project - 1.0-SNAPSHOT + 1.1.0-SNAPSHOT ../../project/pom.xml org.jclouds.provider diff --git a/providers/ninefold-storage/pom.xml b/providers/ninefold-storage/pom.xml index bf6230ad8f..fd9d299f3e 100644 --- a/providers/ninefold-storage/pom.xml +++ b/providers/ninefold-storage/pom.xml @@ -20,13 +20,12 @@ --> - + 4.0.0 org.jclouds jclouds-project - 1.0-SNAPSHOT + 1.1.0-SNAPSHOT ../../project/pom.xml org.jclouds.provider diff --git a/providers/openhosting-east1/pom.xml b/providers/openhosting-east1/pom.xml index 4bd389b46e..13a3f994cd 100644 --- a/providers/openhosting-east1/pom.xml +++ b/providers/openhosting-east1/pom.xml @@ -20,13 +20,12 @@ --> - + 4.0.0 org.jclouds jclouds-project - 1.0-SNAPSHOT + 1.1.0-SNAPSHOT ../../project/pom.xml org.jclouds.provider diff --git a/providers/pom.xml b/providers/pom.xml index 2529f07909..aee01547f0 100644 --- a/providers/pom.xml +++ b/providers/pom.xml @@ -25,7 +25,7 @@ jclouds-project org.jclouds - 1.0-SNAPSHOT + 1.1.0-SNAPSHOT ../project/pom.xml org.jclouds.provider diff --git a/providers/rimuhosting/pom.xml b/providers/rimuhosting/pom.xml index 234f429f1d..a1de6cedb0 100644 --- a/providers/rimuhosting/pom.xml +++ b/providers/rimuhosting/pom.xml @@ -20,13 +20,12 @@ --> - + 4.0.0 org.jclouds jclouds-project - 1.0-SNAPSHOT + 1.1.0-SNAPSHOT ../../project/pom.xml org.jclouds.provider diff --git a/providers/savvis-symphonyvpdc/pom.xml b/providers/savvis-symphonyvpdc/pom.xml index 529e9e254f..0d1967cf66 100644 --- a/providers/savvis-symphonyvpdc/pom.xml +++ b/providers/savvis-symphonyvpdc/pom.xml @@ -27,7 +27,7 @@ org.jclouds jclouds-project - 1.0-SNAPSHOT + 1.1.0-SNAPSHOT ../../project/pom.xml org.jclouds.provider diff --git a/providers/serverlove-z1-man/pom.xml b/providers/serverlove-z1-man/pom.xml index 5202e05444..80eac56790 100644 --- a/providers/serverlove-z1-man/pom.xml +++ b/providers/serverlove-z1-man/pom.xml @@ -20,13 +20,12 @@ --> - + 4.0.0 org.jclouds jclouds-project - 1.0-SNAPSHOT + 1.1.0-SNAPSHOT ../../project/pom.xml org.jclouds.provider diff --git a/providers/skalicloud-sdg-my/pom.xml b/providers/skalicloud-sdg-my/pom.xml index f164b3f3db..ed9699511a 100644 --- a/providers/skalicloud-sdg-my/pom.xml +++ b/providers/skalicloud-sdg-my/pom.xml @@ -20,13 +20,12 @@ --> - + 4.0.0 org.jclouds jclouds-project - 1.0-SNAPSHOT + 1.1.0-SNAPSHOT ../../project/pom.xml org.jclouds.provider diff --git a/providers/slicehost/pom.xml b/providers/slicehost/pom.xml index 4965c905ad..4292e700f9 100644 --- a/providers/slicehost/pom.xml +++ b/providers/slicehost/pom.xml @@ -19,13 +19,12 @@ ==================================================================== --> - + 4.0.0 org.jclouds jclouds-project - 1.0-SNAPSHOT + 1.1.0-SNAPSHOT ../../project/pom.xml org.jclouds.provider diff --git a/providers/stratogen-vcloud-mycloud/pom.xml b/providers/stratogen-vcloud-mycloud/pom.xml index 445159ddc9..1e70a2917a 100644 --- a/providers/stratogen-vcloud-mycloud/pom.xml +++ b/providers/stratogen-vcloud-mycloud/pom.xml @@ -20,13 +20,12 @@ --> - + 4.0.0 org.jclouds jclouds-project - 1.0-SNAPSHOT + 1.1.0-SNAPSHOT ../../project/pom.xml org.jclouds.provider diff --git a/providers/synaptic-storage/pom.xml b/providers/synaptic-storage/pom.xml index 8cacb47f7b..352c9dfb8b 100644 --- a/providers/synaptic-storage/pom.xml +++ b/providers/synaptic-storage/pom.xml @@ -20,13 +20,12 @@ --> - + 4.0.0 org.jclouds jclouds-project - 1.0-SNAPSHOT + 1.1.0-SNAPSHOT ../../project/pom.xml org.jclouds.provider diff --git a/providers/trmk-ecloud/pom.xml b/providers/trmk-ecloud/pom.xml index 004c9c2418..b4bd4af5ab 100644 --- a/providers/trmk-ecloud/pom.xml +++ b/providers/trmk-ecloud/pom.xml @@ -20,13 +20,12 @@ --> - + 4.0.0 org.jclouds jclouds-project - 1.0-SNAPSHOT + 1.1.0-SNAPSHOT ../../project/pom.xml org.jclouds.provider diff --git a/providers/trmk-vcloudexpress/pom.xml b/providers/trmk-vcloudexpress/pom.xml index 4c888bde75..272a91e6ab 100644 --- a/providers/trmk-vcloudexpress/pom.xml +++ b/providers/trmk-vcloudexpress/pom.xml @@ -20,13 +20,12 @@ --> - + 4.0.0 org.jclouds jclouds-project - 1.0-SNAPSHOT + 1.1.0-SNAPSHOT ../../project/pom.xml org.jclouds.provider diff --git a/resources/pom.xml b/resources/pom.xml index 35b955d827..d774cfe2fa 100644 --- a/resources/pom.xml +++ b/resources/pom.xml @@ -25,7 +25,7 @@ jclouds-project org.jclouds - 1.0-SNAPSHOT + 1.1.0-SNAPSHOT ../project/pom.xml jclouds-resources diff --git a/scriptbuilder/pom.xml b/scriptbuilder/pom.xml index 925f3bf09e..9ad082d9da 100644 --- a/scriptbuilder/pom.xml +++ b/scriptbuilder/pom.xml @@ -20,13 +20,12 @@ --> - + 4.0.0 org.jclouds jclouds-project - 1.0-SNAPSHOT + 1.1.0-SNAPSHOT ../project/pom.xml jclouds-scriptbuilder @@ -34,7 +33,7 @@ creates scripts that can be used to manage services bundle - + diff --git a/skeletons/pom.xml b/skeletons/pom.xml index ca07ccd404..23107f221a 100644 --- a/skeletons/pom.xml +++ b/skeletons/pom.xml @@ -24,7 +24,7 @@ jclouds-project org.jclouds - 1.0-SNAPSHOT + 1.1.0-SNAPSHOT ../project/pom.xml 4.0.0 diff --git a/skeletons/standalone-compute/pom.xml b/skeletons/standalone-compute/pom.xml index c172a9e999..a67980f22a 100644 --- a/skeletons/standalone-compute/pom.xml +++ b/skeletons/standalone-compute/pom.xml @@ -19,13 +19,12 @@ ==================================================================== --> - + 4.0.0 org.jclouds jclouds-project - 1.0-SNAPSHOT + 1.1.0-SNAPSHOT ../../project/pom.xml org.jclouds.api From 14b9ac11021cf06b177030d75d6fdef408b0db28 Mon Sep 17 00:00:00 2001 From: Andrew Phillips Date: Sun, 5 Jun 2011 11:19:14 +0400 Subject: [PATCH 061/264] Updated README to reflect new version --- README.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.txt b/README.txt index fef2aa95f4..7f0b67a9eb 100644 --- a/README.txt +++ b/README.txt @@ -8,7 +8,8 @@ bootstrap machines in the cloud. blobstore helps you manage key-value data. our current version is 1.0.0 -our dev version is 1.0-SNAPSHOT +our next maintenance version is 1.0.1-SNAPSHOT +our dev version is 1.1.0-SNAPSHOT check out our examples site! https://github.com/jclouds/jclouds-examples From 25dcc49aa360bda701bf8f4b184c70439f73f20b Mon Sep 17 00:00:00 2001 From: Adrian Cole Date: Wed, 8 Jun 2011 08:20:54 +0800 Subject: [PATCH 062/264] instructions for elasticstack --- .../src/main/resources/preinstalled_images.readme | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 apis/elasticstack/src/main/resources/preinstalled_images.readme diff --git a/apis/elasticstack/src/main/resources/preinstalled_images.readme b/apis/elasticstack/src/main/resources/preinstalled_images.readme new file mode 100644 index 0000000000..5f6bb69979 --- /dev/null +++ b/apis/elasticstack/src/main/resources/preinstalled_images.readme @@ -0,0 +1,7 @@ +the images collection listed in the computeservice api is populated from preinstalled_images.json in a resource path corresponding to the provider name. There's no way to list standard images via api in cloudstack installs. This is the process: + 1. log into the portal + 2. View Source + 3. look for the image you want ex 'Debian Linux 6.0.1' + 4. find the UUID, which will look like: 6aa953cc-3395-4e8d-938e-65c74fd20334 + +Other details can be found by contacting the provider and asking them From 98ffa9c4b550fe126b2e33ba7cabe574eaa53dfe Mon Sep 17 00:00:00 2001 From: Ben Mabey Date: Fri, 17 Jun 2011 09:29:01 -0600 Subject: [PATCH 063/264] fixes typo in clj blobstores to allow for blob-last-modified accessors --- blobstore/src/main/clojure/org/jclouds/blobstore.clj | 2 +- blobstore/src/main/clojure/org/jclouds/blobstore2.clj | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/blobstore/src/main/clojure/org/jclouds/blobstore.clj b/blobstore/src/main/clojure/org/jclouds/blobstore.clj index 60c12eed57..f6239eb6bb 100644 --- a/blobstore/src/main/clojure/org/jclouds/blobstore.clj +++ b/blobstore/src/main/clojure/org/jclouds/blobstore.clj @@ -454,7 +454,7 @@ container, name, string -> etag" (download-blob container-name name (FileOutputStream. target) blobstore)) (define-accessors StorageMetadata "blob" type id name - location-id uri last-modfied) + location-id uri last-modified) (define-accessors BlobMetadata "blob" content-type) (defn blob-etag [blob] diff --git a/blobstore/src/main/clojure/org/jclouds/blobstore2.clj b/blobstore/src/main/clojure/org/jclouds/blobstore2.clj index d98dc74ad8..d1dfcbd47b 100644 --- a/blobstore/src/main/clojure/org/jclouds/blobstore2.clj +++ b/blobstore/src/main/clojure/org/jclouds/blobstore2.clj @@ -341,7 +341,7 @@ Options can also be specified for extension modules (.build blob-builder)))) (define-accessors StorageMetadata "blob" type id name - location-id uri last-modfied) + location-id uri last-modified) (define-accessors BlobMetadata "blob" content-type) (defn blob-etag [blob] From 57fe96d99e8fb5773003dd7e59eb4cf4f1eeb835 Mon Sep 17 00:00:00 2001 From: Andrew Phillips Date: Sun, 19 Jun 2011 16:33:48 -0400 Subject: [PATCH 064/264] Removed the maven-emma-plugin from the 2.x site build since the emma-maven-plugin is already being used --- project/pom.xml | 1 - 1 file changed, 1 deletion(-) diff --git a/project/pom.xml b/project/pom.xml index 101dd59cb9..82395073d1 100644 --- a/project/pom.xml +++ b/project/pom.xml @@ -768,7 +768,6 @@ pageTracker._trackPageview(); rat-report source-repository surefire-report - maven-emma-plugin team-list From 797e75d4f0fa0f6178f56065a56b7f9925fc539f Mon Sep 17 00:00:00 2001 From: Andrew Phillips Date: Sun, 19 Jun 2011 19:39:07 -0400 Subject: [PATCH 065/264] [issue 531] Creating site files in UTF-8 --- project/pom.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/project/pom.xml b/project/pom.xml index 82395073d1..7c5c2d5fa1 100644 --- a/project/pom.xml +++ b/project/pom.xml @@ -502,6 +502,7 @@ pageTracker._trackPageview(); maven-site-plugin + ${project.build.sourceEncoding} ${project.distributionManagement.site.id} ${project.distributionManagement.site.url} From 783f137bb59e645880d30e4b70b52c4aba90ef0b Mon Sep 17 00:00:00 2001 From: Andrew Phillips Date: Tue, 21 Jun 2011 18:32:42 +0200 Subject: [PATCH 066/264] Using the correct "it's me" header in the RUN@cloud integration tests --- .../jclouds/demo/tweetstore/integration/TweetStoreLiveTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/demos/tweetstore/runatcloud-tweetstore/src/test/java/org/jclouds/demo/tweetstore/integration/TweetStoreLiveTest.java b/demos/tweetstore/runatcloud-tweetstore/src/test/java/org/jclouds/demo/tweetstore/integration/TweetStoreLiveTest.java index 929537c037..174b2e95fc 100644 --- a/demos/tweetstore/runatcloud-tweetstore/src/test/java/org/jclouds/demo/tweetstore/integration/TweetStoreLiveTest.java +++ b/demos/tweetstore/runatcloud-tweetstore/src/test/java/org/jclouds/demo/tweetstore/integration/TweetStoreLiveTest.java @@ -202,7 +202,7 @@ public class TweetStoreLiveTest { for (String context : blobstores) { System.out.println("storing at context: " + context); HttpURLConnection connection = (HttpURLConnection) gurl.openConnection(); - connection.addRequestProperty("X-AppEngine-QueueName", "twitter"); + connection.addRequestProperty("X-RUN@cloud-Submitter", "twitter"); connection.addRequestProperty("context", context); InputStream i = connection.getInputStream(); String string = Strings2.toStringAndClose(i); From f89a213843d22974aece6b3ec26ce9bb72e6119d Mon Sep 17 00:00:00 2001 From: Andrew Phillips Date: Thu, 23 Jun 2011 01:02:00 +0200 Subject: [PATCH 067/264] Updated the sandbox POMs to the new 1.1.0-SNAPSHOT version, since the maven-release-plugin didn't --- sandbox-apis/cloudstack/pom.xml | 2 +- sandbox-apis/cloudwatch/pom.xml | 2 +- sandbox-apis/elb/pom.xml | 2 +- sandbox-apis/libvirt/pom.xml | 2 +- sandbox-apis/nirvanix/pom.xml | 2 +- sandbox-apis/pcs/pom.xml | 2 +- sandbox-apis/scality-rs2/pom.xml | 2 +- sandbox-apis/simpledb/pom.xml | 2 +- sandbox-apis/sqs/pom.xml | 2 +- sandbox-drivers/asynchttpclient/pom.xml | 2 +- sandbox-providers/aws-elb/pom.xml | 2 +- sandbox-providers/aws-simpledb/pom.xml | 2 +- sandbox-providers/azurequeue/pom.xml | 2 +- sandbox-providers/boxdotnet/pom.xml | 2 +- sandbox-providers/googlestorage/pom.xml | 2 +- sandbox-providers/hosteurope-storage/pom.xml | 2 +- sandbox-providers/ibm-smartcloud/pom.xml | 2 +- sandbox-providers/scaleup-storage/pom.xml | 2 +- sandbox-providers/softlayer/pom.xml | 2 +- sandbox-providers/tiscali-storage/pom.xml | 2 +- sandbox-providers/twitter/pom.xml | 2 +- 21 files changed, 21 insertions(+), 21 deletions(-) diff --git a/sandbox-apis/cloudstack/pom.xml b/sandbox-apis/cloudstack/pom.xml index 8f5c415ea4..8afaca897c 100644 --- a/sandbox-apis/cloudstack/pom.xml +++ b/sandbox-apis/cloudstack/pom.xml @@ -27,7 +27,7 @@ org.jclouds jclouds-project - 1.0-SNAPSHOT + 1.1.0-SNAPSHOT ../../project/pom.xml org.jclouds.api diff --git a/sandbox-apis/cloudwatch/pom.xml b/sandbox-apis/cloudwatch/pom.xml index a2b05b7aa9..4941c5fa39 100644 --- a/sandbox-apis/cloudwatch/pom.xml +++ b/sandbox-apis/cloudwatch/pom.xml @@ -26,7 +26,7 @@ org.jclouds jclouds-project - 1.0-SNAPSHOT + 1.1.0-SNAPSHOT ../../project/pom.xml org.jclouds.api diff --git a/sandbox-apis/elb/pom.xml b/sandbox-apis/elb/pom.xml index 5b0b380060..387ed36b29 100644 --- a/sandbox-apis/elb/pom.xml +++ b/sandbox-apis/elb/pom.xml @@ -26,7 +26,7 @@ org.jclouds jclouds-project - 1.0-SNAPSHOT + 1.1.0-SNAPSHOT ../../project/pom.xml org.jclouds.api diff --git a/sandbox-apis/libvirt/pom.xml b/sandbox-apis/libvirt/pom.xml index 43b9a625ea..50871c1158 100644 --- a/sandbox-apis/libvirt/pom.xml +++ b/sandbox-apis/libvirt/pom.xml @@ -25,7 +25,7 @@ org.jclouds jclouds-project - 1.0-SNAPSHOT + 1.1.0-SNAPSHOT ../../project/pom.xml org.jclouds.api diff --git a/sandbox-apis/nirvanix/pom.xml b/sandbox-apis/nirvanix/pom.xml index ac5549c642..e3210d1639 100644 --- a/sandbox-apis/nirvanix/pom.xml +++ b/sandbox-apis/nirvanix/pom.xml @@ -25,7 +25,7 @@ org.jclouds jclouds-project - 1.0-SNAPSHOT + 1.1.0-SNAPSHOT ../../project/pom.xml org.jclouds.provider diff --git a/sandbox-apis/pcs/pom.xml b/sandbox-apis/pcs/pom.xml index 2ef6344198..22ebf9c7c4 100644 --- a/sandbox-apis/pcs/pom.xml +++ b/sandbox-apis/pcs/pom.xml @@ -25,7 +25,7 @@ org.jclouds jclouds-project - 1.0-SNAPSHOT + 1.1.0-SNAPSHOT ../../project/pom.xml org.jclouds.api diff --git a/sandbox-apis/scality-rs2/pom.xml b/sandbox-apis/scality-rs2/pom.xml index 4191aa583b..ea1a712a29 100644 --- a/sandbox-apis/scality-rs2/pom.xml +++ b/sandbox-apis/scality-rs2/pom.xml @@ -26,7 +26,7 @@ org.jclouds jclouds-project - 1.0-SNAPSHOT + 1.1.0-SNAPSHOT ../../project/pom.xml org.jclouds.api diff --git a/sandbox-apis/simpledb/pom.xml b/sandbox-apis/simpledb/pom.xml index 088e01feb2..d20f887b43 100644 --- a/sandbox-apis/simpledb/pom.xml +++ b/sandbox-apis/simpledb/pom.xml @@ -26,7 +26,7 @@ org.jclouds jclouds-project - 1.0-SNAPSHOT + 1.1.0-SNAPSHOT ../../project/pom.xml org.jclouds.api diff --git a/sandbox-apis/sqs/pom.xml b/sandbox-apis/sqs/pom.xml index d05dd450b5..23595315fc 100644 --- a/sandbox-apis/sqs/pom.xml +++ b/sandbox-apis/sqs/pom.xml @@ -26,7 +26,7 @@ org.jclouds jclouds-project - 1.0-SNAPSHOT + 1.1.0-SNAPSHOT ../../project/pom.xml org.jclouds.api diff --git a/sandbox-drivers/asynchttpclient/pom.xml b/sandbox-drivers/asynchttpclient/pom.xml index ad1349d179..6543e5c119 100644 --- a/sandbox-drivers/asynchttpclient/pom.xml +++ b/sandbox-drivers/asynchttpclient/pom.xml @@ -25,7 +25,7 @@ org.jclouds jclouds-project - 1.0-SNAPSHOT + 1.1.0-SNAPSHOT ../../project/pom.xml org.jclouds.driver diff --git a/sandbox-providers/aws-elb/pom.xml b/sandbox-providers/aws-elb/pom.xml index 3cd74042f0..32a7533c9a 100644 --- a/sandbox-providers/aws-elb/pom.xml +++ b/sandbox-providers/aws-elb/pom.xml @@ -26,7 +26,7 @@ org.jclouds jclouds-project - 1.0-SNAPSHOT + 1.1.0-SNAPSHOT ../../project/pom.xml org.jclouds.provider diff --git a/sandbox-providers/aws-simpledb/pom.xml b/sandbox-providers/aws-simpledb/pom.xml index b3b91898c5..7696e83bb2 100644 --- a/sandbox-providers/aws-simpledb/pom.xml +++ b/sandbox-providers/aws-simpledb/pom.xml @@ -26,7 +26,7 @@ org.jclouds jclouds-project - 1.0-SNAPSHOT + 1.1.0-SNAPSHOT ../../project/pom.xml org.jclouds.provider diff --git a/sandbox-providers/azurequeue/pom.xml b/sandbox-providers/azurequeue/pom.xml index beeacf0e25..f1508d955c 100644 --- a/sandbox-providers/azurequeue/pom.xml +++ b/sandbox-providers/azurequeue/pom.xml @@ -26,7 +26,7 @@ org.jclouds jclouds-project - 1.0-SNAPSHOT + 1.1.0-SNAPSHOT ../../project/pom.xml org.jclouds.provider diff --git a/sandbox-providers/boxdotnet/pom.xml b/sandbox-providers/boxdotnet/pom.xml index 433628602f..1d84b1e327 100644 --- a/sandbox-providers/boxdotnet/pom.xml +++ b/sandbox-providers/boxdotnet/pom.xml @@ -30,7 +30,7 @@ org.jclouds jclouds-project - 1.0-SNAPSHOT + 1.1.0-SNAPSHOT ../../project/pom.xml org.jclouds.provider diff --git a/sandbox-providers/googlestorage/pom.xml b/sandbox-providers/googlestorage/pom.xml index 1f4b81442a..17ea7484e9 100644 --- a/sandbox-providers/googlestorage/pom.xml +++ b/sandbox-providers/googlestorage/pom.xml @@ -26,7 +26,7 @@ org.jclouds jclouds-project - 1.0-SNAPSHOT + 1.1.0-SNAPSHOT ../../project/pom.xml org.jclouds.provider diff --git a/sandbox-providers/hosteurope-storage/pom.xml b/sandbox-providers/hosteurope-storage/pom.xml index 2777fe6129..043177b505 100644 --- a/sandbox-providers/hosteurope-storage/pom.xml +++ b/sandbox-providers/hosteurope-storage/pom.xml @@ -26,7 +26,7 @@ org.jclouds jclouds-project - 1.0-SNAPSHOT + 1.1.0-SNAPSHOT ../../project/pom.xml org.jclouds.provider diff --git a/sandbox-providers/ibm-smartcloud/pom.xml b/sandbox-providers/ibm-smartcloud/pom.xml index 1938d8d2e3..bee405ad6b 100644 --- a/sandbox-providers/ibm-smartcloud/pom.xml +++ b/sandbox-providers/ibm-smartcloud/pom.xml @@ -30,7 +30,7 @@ org.jclouds jclouds-project - 1.0-SNAPSHOT + 1.1.0-SNAPSHOT ../../project/pom.xml org.jclouds.provider diff --git a/sandbox-providers/scaleup-storage/pom.xml b/sandbox-providers/scaleup-storage/pom.xml index e467e2d68b..cc2fbe3a4f 100644 --- a/sandbox-providers/scaleup-storage/pom.xml +++ b/sandbox-providers/scaleup-storage/pom.xml @@ -26,7 +26,7 @@ org.jclouds jclouds-project - 1.0-SNAPSHOT + 1.1.0-SNAPSHOT ../../project/pom.xml org.jclouds.provider diff --git a/sandbox-providers/softlayer/pom.xml b/sandbox-providers/softlayer/pom.xml index 2348d8e0b8..67cbd3a6b4 100644 --- a/sandbox-providers/softlayer/pom.xml +++ b/sandbox-providers/softlayer/pom.xml @@ -30,7 +30,7 @@ org.jclouds jclouds-project - 1.0-SNAPSHOT + 1.1.0-SNAPSHOT ../../project/pom.xml org.jclouds.provider diff --git a/sandbox-providers/tiscali-storage/pom.xml b/sandbox-providers/tiscali-storage/pom.xml index aa892c5ba7..dd0fa1a6da 100644 --- a/sandbox-providers/tiscali-storage/pom.xml +++ b/sandbox-providers/tiscali-storage/pom.xml @@ -26,7 +26,7 @@ org.jclouds jclouds-project - 1.0-SNAPSHOT + 1.1.0-SNAPSHOT ../../project/pom.xml org.jclouds.provider diff --git a/sandbox-providers/twitter/pom.xml b/sandbox-providers/twitter/pom.xml index f826bb00c7..adb60082a3 100644 --- a/sandbox-providers/twitter/pom.xml +++ b/sandbox-providers/twitter/pom.xml @@ -27,7 +27,7 @@ org.jclouds jclouds-project - 1.0-SNAPSHOT + 1.1.0-SNAPSHOT ../../project/pom.xml org.jclouds.provider From 3e80c0433c68057e5b157deb8bf97b4801da4792 Mon Sep 17 00:00:00 2001 From: Adrian Cole Date: Fri, 24 Jun 2011 18:44:16 +0800 Subject: [PATCH 068/264] osgi fix --- providers/aws-ec2/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/providers/aws-ec2/pom.xml b/providers/aws-ec2/pom.xml index cfa2c564f1..3979bcdd0e 100644 --- a/providers/aws-ec2/pom.xml +++ b/providers/aws-ec2/pom.xml @@ -150,7 +150,7 @@ ${project.artifactId} org.jclouds.aws.ec2.*;version="${project.version}" - org.jclouds.*;version="${project.version}",* + org.jclouds.*;version="${project.version}",org.jclouds.aws;version="${project.version}",* From a9277558cd97c5d313259fe831fdc43111c669c9 Mon Sep 17 00:00:00 2001 From: Adrian Cole Date: Mon, 27 Jun 2011 02:23:14 -0700 Subject: [PATCH 069/264] Issue 609:support same arity operations on rest services --- .../internal/RestAnnotationProcessor.java | 15 ++++++---- .../internal/RestAnnotationProcessorTest.java | 28 +++++++++++++------ 2 files changed, 29 insertions(+), 14 deletions(-) diff --git a/core/src/main/java/org/jclouds/rest/internal/RestAnnotationProcessor.java b/core/src/main/java/org/jclouds/rest/internal/RestAnnotationProcessor.java index 36627ff5df..5b1d294ddc 100644 --- a/core/src/main/java/org/jclouds/rest/internal/RestAnnotationProcessor.java +++ b/core/src/main/java/org/jclouds/rest/internal/RestAnnotationProcessor.java @@ -178,7 +178,7 @@ public class RestAnnotationProcessor { static Map>> createMethodToIndexOfParamToAnnotation( final Class annotation) { return new MapMaker().makeComputingMap(new Function>>() { - public Map> apply(final Method method) { + public Map> apply(Method method) { return new MapMaker().makeComputingMap(new GetAnnotationsForMethodParameterIndex(method, annotation)); } }); @@ -218,7 +218,7 @@ public class RestAnnotationProcessor { static final Map> methodToIndexesOfOptions = new MapMaker() .makeComputingMap(new Function>() { - public Set apply(final Method method) { + public Set apply(Method method) { Builder toReturn = ImmutableSet. builder(); for (int index = 0; index < method.getParameterTypes().length; index++) { Class type = method.getParameterTypes()[index]; @@ -307,7 +307,7 @@ public class RestAnnotationProcessor { int result = 1; result = prime * result + ((declaringPackage == null) ? 0 : declaringPackage.hashCode()); result = prime * result + ((name == null) ? 0 : name.hashCode()); - result = prime * result + parameterCount; + result = prime * result + parametersTypeHashCode; return result; } @@ -330,19 +330,22 @@ public class RestAnnotationProcessor { return false; } else if (!name.equals(other.name)) return false; - if (parameterCount != other.parameterCount) + if (parametersTypeHashCode != other.parametersTypeHashCode) return false; return true; } private final String name; - private final int parameterCount; + private final int parametersTypeHashCode; private final Package declaringPackage; public MethodKey(Method method) { this.name = method.getName(); this.declaringPackage = method.getDeclaringClass().getPackage(); - this.parameterCount = method.getParameterTypes().length; + int parametersTypeHashCode = 0; + for (Class param: method.getParameterTypes()) + parametersTypeHashCode +=param.hashCode(); + this.parametersTypeHashCode = parametersTypeHashCode; } } diff --git a/core/src/test/java/org/jclouds/rest/internal/RestAnnotationProcessorTest.java b/core/src/test/java/org/jclouds/rest/internal/RestAnnotationProcessorTest.java index 7bc2fe2e06..d94e3081d3 100644 --- a/core/src/test/java/org/jclouds/rest/internal/RestAnnotationProcessorTest.java +++ b/core/src/test/java/org/jclouds/rest/internal/RestAnnotationProcessorTest.java @@ -307,8 +307,8 @@ public class RestAnnotationProcessorTest extends BaseRestClientTest { } Caller caller = child.getInstance(Caller.class); - expect(mock.submit(requestLineEquals("GET http://howdyboys/client/1/foo HTTP/1.1"), eq(function))) - .andReturn(Futures. immediateFuture(null)).atLeastOnce(); + expect(mock.submit(requestLineEquals("GET http://howdyboys/client/1/foo HTTP/1.1"), eq(function))).andReturn( + Futures. immediateFuture(null)).atLeastOnce(); replay(mock); caller.getCallee(URI.create("http://howdyboys")).onePath("foo"); @@ -834,13 +834,13 @@ public class RestAnnotationProcessorTest extends BaseRestClientTest { @Unwrap(depth = 2) @Consumes(MediaType.APPLICATION_JSON) ListenableFuture testUnwrapDepth2Long(); - + @GET @Path("/") @Unwrap(depth = 2, edgeCollection = Set.class) @Consumes(MediaType.APPLICATION_JSON) ListenableFuture testUnwrapDepth2Set(); - + @GET @Path("/") @Unwrap(depth = 3, edgeCollection = Set.class) @@ -854,8 +854,12 @@ public class RestAnnotationProcessorTest extends BaseRestClientTest { } @ROWDY - @Path("/objects/{id}") + @Path("/strings/{id}") ListenableFuture rowdy(@PathParam("id") String path); + + @ROWDY + @Path("/ints/{id}") + ListenableFuture rowdy(@PathParam("id") int path); } static class Wrapper { @@ -866,7 +870,16 @@ public class RestAnnotationProcessorTest extends BaseRestClientTest { Method method = TestPut.class.getMethod("rowdy", String.class); HttpRequest request = factory(TestPut.class).createRequest(method, "data"); - assertRequestLineEquals(request, "ROWDY http://localhost:9999/objects/data HTTP/1.1"); + assertRequestLineEquals(request, "ROWDY http://localhost:9999/strings/data HTTP/1.1"); + assertNonPayloadHeadersEqual(request, ""); + assertPayloadEquals(request, null, null, false); + } + + public void testAlternateHttpMethodSameArity() throws SecurityException, NoSuchMethodException, IOException { + Method method = TestPut.class.getMethod("rowdy", int.class); + HttpRequest request = factory(TestPut.class).createRequest(method, "data"); + + assertRequestLineEquals(request, "ROWDY http://localhost:9999/ints/data HTTP/1.1"); assertNonPayloadHeadersEqual(request, ""); assertPayloadEquals(request, null, null, false); } @@ -1051,8 +1064,7 @@ public class RestAnnotationProcessorTest extends BaseRestClientTest { Function> parser = (Function>) RestAnnotationProcessor .createResponseParser(parserFactory, injector, method, request); - assertEquals(parser.apply(new HttpResponse(200, "ok", - newStringPayload("{\"runit\":[\"0.7.0\"]}"))), "0.7.0"); + assertEquals(parser.apply(new HttpResponse(200, "ok", newStringPayload("{\"runit\":[\"0.7.0\"]}"))), "0.7.0"); assertEquals(parser.apply(new HttpResponse(200, "ok", newStringPayload("{\"runit\":[]}"))), null); } From 0502300840ad1b5764986c34cca7c1946ecf8ded Mon Sep 17 00:00:00 2001 From: Adrian Cole Date: Mon, 27 Jun 2011 02:26:51 -0700 Subject: [PATCH 070/264] fixed ec2 security group live test --- .../services/SecurityGroupClientLiveTest.java | 156 +++++++++++------- .../AWSSecurityGroupClientLiveTest.java | 62 +++++++ 2 files changed, 157 insertions(+), 61 deletions(-) create mode 100644 providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/AWSSecurityGroupClientLiveTest.java diff --git a/apis/ec2/src/test/java/org/jclouds/ec2/services/SecurityGroupClientLiveTest.java b/apis/ec2/src/test/java/org/jclouds/ec2/services/SecurityGroupClientLiveTest.java index 93bd25dc98..d8e0bff1a5 100644 --- a/apis/ec2/src/test/java/org/jclouds/ec2/services/SecurityGroupClientLiveTest.java +++ b/apis/ec2/src/test/java/org/jclouds/ec2/services/SecurityGroupClientLiveTest.java @@ -26,8 +26,6 @@ import java.util.Iterator; import java.util.Properties; import java.util.Set; import java.util.SortedSet; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.TimeoutException; import org.jclouds.Constants; import org.jclouds.aws.domain.Region; @@ -44,9 +42,11 @@ import org.testng.annotations.AfterTest; import org.testng.annotations.BeforeGroups; import org.testng.annotations.Test; +import com.google.common.base.Predicate; import com.google.common.collect.ImmutableSet; +import com.google.common.collect.ImmutableSortedSet; +import com.google.common.collect.Iterables; import com.google.common.collect.Lists; -import com.google.common.collect.Sets; import com.google.inject.Module; /** @@ -54,7 +54,7 @@ import com.google.inject.Module; * * @author Adrian Cole */ -@Test(groups = "live", sequential = true) +@Test(groups = "live", singleThreaded = true) public class SecurityGroupClientLiveTest { private SecurityGroupClient client; @@ -98,13 +98,14 @@ public class SecurityGroupClientLiveTest { @Test void testDescribe() { for (String region : Lists.newArrayList(null, Region.EU_WEST_1, Region.US_EAST_1, Region.US_WEST_1, - Region.AP_SOUTHEAST_1)) { - SortedSet allResults = Sets.newTreeSet(client.describeSecurityGroupsInRegion(region)); + Region.AP_SOUTHEAST_1, Region.AP_NORTHEAST_1)) { + SortedSet allResults = ImmutableSortedSet. copyOf(client + .describeSecurityGroupsInRegion(region)); assertNotNull(allResults); if (allResults.size() >= 1) { SecurityGroup group = allResults.last(); - SortedSet result = Sets.newTreeSet(client.describeSecurityGroupsInRegion(region, group - .getName())); + SortedSet result = ImmutableSortedSet. copyOf(client + .describeSecurityGroupsInRegion(region, group.getName())); assertNotNull(result); SecurityGroup compare = result.last(); assertEquals(compare, group); @@ -115,29 +116,56 @@ public class SecurityGroupClientLiveTest { @Test void testCreateSecurityGroup() { String groupName = PREFIX + "1"; - String groupDescription = PREFIX + "1 description"; - client.deleteSecurityGroupInRegion(null, groupName); - client.deleteSecurityGroupInRegion(null, groupName); + cleanupAndSleep(groupName); + try { + String groupDescription = PREFIX + "1 description"; + client.deleteSecurityGroupInRegion(null, groupName); + client.createSecurityGroupInRegion(null, groupName, groupDescription); + verifySecurityGroup(groupName, groupDescription); + } finally { + client.deleteSecurityGroupInRegion(null, groupName); + } + } - client.createSecurityGroupInRegion(null, groupName, groupDescription); + private void cleanupAndSleep(String groupName) { + try { + client.deleteSecurityGroupInRegion(null, groupName); + Thread.sleep(2000); + } catch (Exception e) { - verifySecurityGroup(groupName, groupDescription); + } } @Test - void testAuthorizeSecurityGroupIngressCidr() throws InterruptedException, ExecutionException, TimeoutException { + void testAuthorizeSecurityGroupIngressCidr() { String groupName = PREFIX + "ingress"; + cleanupAndSleep(groupName); + try { + client.createSecurityGroupInRegion(null, groupName, groupName); + client.authorizeSecurityGroupIngressInRegion(null, groupName, IpProtocol.TCP, 80, 80, "0.0.0.0/0"); + assertEventually(new GroupHasPermission(client, groupName, new TCPPort80AllIPs())); - client.deleteSecurityGroupInRegion(null, groupName); + client.revokeSecurityGroupIngressInRegion(null, groupName, IpProtocol.TCP, 80, 80, "0.0.0.0/0"); + assertEventually(new GroupHasNoPermissions(client, groupName)); + } finally { + client.deleteSecurityGroupInRegion(null, groupName); + } + } - client.createSecurityGroupInRegion(null, groupName, groupName); - client.authorizeSecurityGroupIngressInRegion(null, groupName, IpProtocol.TCP, 80, 80, "0.0.0.0/0"); - assertEventually(new GroupHasPermission(client, groupName, new IpPermission(80, 80, Sets - . newLinkedHashSet(), IpProtocol.TCP, ImmutableSet.of("0.0.0.0/0")))); - - client.revokeSecurityGroupIngressInRegion(null, groupName, IpProtocol.TCP, 80, 80, "0.0.0.0/0"); - assertEventually(new GroupHasNoPermissions(client, groupName)); + @Test + void testAuthorizeSecurityGroupIngressSourcePort() { + String groupName = PREFIX + "ingress"; + cleanupAndSleep(groupName); + try { + client.createSecurityGroupInRegion(null, groupName, groupName); + client.authorizeSecurityGroupIngressInRegion(null, groupName, IpProtocol.TCP, 80, 80, "0.0.0.0/0"); + assertEventually(new GroupHasPermission(client, groupName, new TCPPort80AllIPs())); + client.revokeSecurityGroupIngressInRegion(null, groupName, IpProtocol.TCP, 80, 80, "0.0.0.0/0"); + assertEventually(new GroupHasNoPermissions(client, groupName)); + } finally { + client.deleteSecurityGroupInRegion(null, groupName); + } } private void verifySecurityGroup(String groupName, String description) { @@ -149,51 +177,55 @@ public class SecurityGroupClientLiveTest { assertEquals(listPair.getDescription(), description); } - @Test(enabled = false) - // TODO - void testAuthorizeSecurityGroupIngressSourceGroup() throws InterruptedException { + @Test + void testAuthorizeSecurityGroupIngressSourceGroup() { String group1Name = PREFIX + "ingress1"; String group2Name = PREFIX + "ingress2"; - + cleanupAndSleep(group2Name); + cleanupAndSleep(group1Name); try { - client.deleteSecurityGroupInRegion(null, group1Name); - } catch (Exception e) { + client.createSecurityGroupInRegion(null, group1Name, group1Name); + client.createSecurityGroupInRegion(null, group2Name, group2Name); + ensureGroupsExist(group1Name, group2Name); + client.authorizeSecurityGroupIngressInRegion(null, group1Name, IpProtocol.TCP, 80, 80, "0.0.0.0/0"); + assertEventually(new GroupHasPermission(client, group1Name, new TCPPort80AllIPs())); + Set oneResult = client.describeSecurityGroupsInRegion(null, group1Name); + assertNotNull(oneResult); + assertEquals(oneResult.size(), 1); + SecurityGroup group = oneResult.iterator().next(); + assertEquals(group.getName(), group1Name); + final UserIdGroupPair to = new UserIdGroupPair(group.getOwnerId(), group1Name); + client.authorizeSecurityGroupIngressInRegion(null, group2Name, to); + assertEventually(new GroupHasPermission(client, group2Name, new Predicate() { + @Override + public boolean apply(IpPermission arg0) { + return arg0.getGroups().equals(ImmutableSet.of(to)); + } + })); - } - try { + client.revokeSecurityGroupIngressInRegion(null, group2Name, + new UserIdGroupPair(group.getOwnerId(), group1Name)); + assertEventually(new GroupHasNoPermissions(client, group2Name)); + } finally { client.deleteSecurityGroupInRegion(null, group2Name); - } catch (Exception e) { - + client.deleteSecurityGroupInRegion(null, group1Name); } + } - client.createSecurityGroupInRegion(null, group1Name, group1Name); - client.createSecurityGroupInRegion(null, group2Name, group2Name); - ensureGroupsExist(group1Name, group2Name); - client.authorizeSecurityGroupIngressInRegion(null, group1Name, IpProtocol.TCP, 80, 80, "0.0.0.0/0"); - assertEventually(new GroupHasPermission(client, group2Name, new IpPermission(80, 80, Sets - . newLinkedHashSet(), IpProtocol.TCP, ImmutableSet.of("0.0.0.0/0")))); - - Set oneResult = client.describeSecurityGroupsInRegion(null, group1Name); - assertNotNull(oneResult); - assertEquals(oneResult.size(), 1); - SecurityGroup group = oneResult.iterator().next(); - assertEquals(group.getName(), group1Name); - - client.authorizeSecurityGroupIngressInRegion(null, group2Name, - new UserIdGroupPair(group.getOwnerId(), group1Name)); - assertEventually(new GroupHasPermission(client, group2Name, new IpPermission(80, 80, Sets - . newLinkedHashSet(), IpProtocol.TCP, ImmutableSet.of("0.0.0.0/0")))); - - client.revokeSecurityGroupIngressInRegion(null, group2Name, new UserIdGroupPair(group.getOwnerId(), group1Name)); - assertEventually(new GroupHasNoPermissions(client, group2Name)); + private final class TCPPort80AllIPs implements Predicate { + @Override + public boolean apply(IpPermission arg0) { + return arg0.getIpProtocol() == IpProtocol.TCP && arg0.getFromPort() == 80 && arg0.getToPort() == 80 + && arg0.getIpRanges().equals(ImmutableSet.of("0.0.0.0/0")); + } } private static final class GroupHasPermission implements Runnable { private final SecurityGroupClient client; private final String group; - private final IpPermission permission; + private final Predicate permission; - private GroupHasPermission(SecurityGroupClient client, String group, IpPermission permission) { + private GroupHasPermission(SecurityGroupClient client, String group, Predicate permission) { this.client = client; this.group = group; this.permission = permission; @@ -202,10 +234,8 @@ public class SecurityGroupClientLiveTest { public void run() { try { Set oneResult = client.describeSecurityGroupsInRegion(null, group); - assertNotNull(oneResult); - assertEquals(oneResult.size(), 1); - SecurityGroup listPair = oneResult.iterator().next(); - assert listPair.getIpPermissions().contains(permission); + assert Iterables.all(Iterables.getOnlyElement(oneResult).getIpPermissions(), permission) : permission + + ": " + oneResult; } catch (Exception e) { throw new AssertionError(e); } @@ -235,7 +265,8 @@ public class SecurityGroupClientLiveTest { } private void ensureGroupsExist(String group1Name, String group2Name) { - Set twoResults = client.describeSecurityGroupsInRegion(null, group1Name, group2Name); + SortedSet twoResults = ImmutableSortedSet.copyOf(client.describeSecurityGroupsInRegion(null, + group1Name, group2Name)); assertNotNull(twoResults); assertEquals(twoResults.size(), 2); Iterator iterator = twoResults.iterator(); @@ -254,7 +285,7 @@ public class SecurityGroupClientLiveTest { * Due to eventual consistency, container commands may not return correctly immediately. Hence, * we will try up to the inconsistency window to see if the assertion completes. */ - protected static void assertEventually(Runnable assertion) throws InterruptedException { + protected static void assertEventually(Runnable assertion) { long start = System.currentTimeMillis(); AssertionError error = null; for (int i = 0; i < 30; i++) { @@ -267,7 +298,10 @@ public class SecurityGroupClientLiveTest { } catch (AssertionError e) { error = e; } - Thread.sleep(INCONSISTENCY_WINDOW / 30); + try { + Thread.sleep(INCONSISTENCY_WINDOW / 30); + } catch (InterruptedException e) { + } } if (error != null) throw error; diff --git a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/AWSSecurityGroupClientLiveTest.java b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/AWSSecurityGroupClientLiveTest.java new file mode 100644 index 0000000000..129bb612c0 --- /dev/null +++ b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/AWSSecurityGroupClientLiveTest.java @@ -0,0 +1,62 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.jclouds.aws.ec2.services; + +import static com.google.common.base.Preconditions.checkNotNull; + +import java.util.Properties; + +import org.jclouds.Constants; +import org.jclouds.ec2.services.SecurityGroupClientLiveTest; +import org.testng.annotations.Test; + +/** + * + * @author Adrian Cole + */ +@Test(groups = "live", singleThreaded = true) +public class AWSSecurityGroupClientLiveTest extends SecurityGroupClientLiveTest { + public AWSSecurityGroupClientLiveTest() { + provider = "aws-ec2"; + } + + @Override + protected void setupCredentials() { + identity = checkNotNull(System.getProperty("test." + provider + ".identity"), "test." + provider + ".identity"); + credential = checkNotNull(System.getProperty("test." + provider + ".credential"), "test." + provider + + ".credential"); + endpoint = System.getProperty("test." + provider + ".endpoint", null); + apiversion = System.getProperty("test." + provider + ".apiversion", null); + } + + @Override + protected Properties setupProperties() { + Properties overrides = new Properties(); + overrides.setProperty(Constants.PROPERTY_TRUST_ALL_CERTS, "true"); + overrides.setProperty(Constants.PROPERTY_RELAX_HOSTNAME, "true"); + overrides.setProperty(provider + ".identity", identity); + overrides.setProperty(provider + ".credential", credential); + if (endpoint != null) + overrides.setProperty(provider + ".endpoint", endpoint); + if (apiversion != null) + overrides.setProperty(provider + ".apiversion", apiversion); + return overrides; + } + +} From 96a4923c4c6b70e39a1896792298d6613e0563d0 Mon Sep 17 00:00:00 2001 From: Adrian Cole Date: Mon, 27 Jun 2011 07:11:10 -0700 Subject: [PATCH 071/264] added message and null check guarding MPU on payloads with contentLength set --- .../strategy/internal/SequentialMultipartUploadStrategy.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/providers/aws-s3/src/main/java/org/jclouds/aws/s3/blobstore/strategy/internal/SequentialMultipartUploadStrategy.java b/providers/aws-s3/src/main/java/org/jclouds/aws/s3/blobstore/strategy/internal/SequentialMultipartUploadStrategy.java index 760744611b..926202f4e4 100644 --- a/providers/aws-s3/src/main/java/org/jclouds/aws/s3/blobstore/strategy/internal/SequentialMultipartUploadStrategy.java +++ b/providers/aws-s3/src/main/java/org/jclouds/aws/s3/blobstore/strategy/internal/SequentialMultipartUploadStrategy.java @@ -92,7 +92,10 @@ public class SequentialMultipartUploadStrategy implements MultipartUploadStrateg String key = blob.getMetadata().getName(); Payload payload = blob.getPayload(); MultipartUploadSlicingAlgorithm algorithm = new MultipartUploadSlicingAlgorithm(); - algorithm.calculateChunkSize(payload.getContentMetadata().getContentLength()); + algorithm + .calculateChunkSize(checkNotNull( + payload.getContentMetadata().getContentLength(), + "contentLength required on all uploads to amazon s3; please invoke payload.getContentMetadata().setContentLength(length) first")); int parts = algorithm.getParts(); long chunkSize = algorithm.getChunkSize(); if (parts > 0) { From cf07d64a480ec6273cdf7fea33344642ef623909 Mon Sep 17 00:00:00 2001 From: Adrian Cole Date: Tue, 28 Jun 2011 11:28:27 -0700 Subject: [PATCH 072/264] Issue 610:add support for Green House Data Element vCloud --- core/src/main/resources/rest.properties | 3 + .../greenhousedata-element-vcloud/pom.xml | 164 +++++++++++++++++ ...nHouseDataElementVCloudContextBuilder.java | 51 ++++++ ...useDataElementVCloudPropertiesBuilder.java | 46 +++++ ...ouseDataElementVCloudProviderMetadata.java | 116 ++++++++++++ ...mentVCloudComputeServiceContextModule.java | 39 ++++ ...ouseDataElementVCloudRestClientModule.java | 34 ++++ .../org.jclouds.providers.ProviderMetadata | 1 + ...nHouseDataElementVCloudClientLiveTest.java | 35 ++++ ...eenHouseDataElementVCloudProviderTest.java | 35 ++++ ...taElementVCloudComputeServiceLiveTest.java | 70 ++++++++ ...aElementVCloudTemplateBuilderLiveTest.java | 72 ++++++++ ...ataElementVCloudCatalogClientLiveTest.java | 35 ++++ ...ataElementVCloudNetworkClientLiveTest.java | 35 ++++ ...useDataElementVCloudOrgClientLiveTest.java | 35 ++++ ...seDataElementVCloudTaskClientLiveTest.java | 35 ++++ ...seDataElementVCloudVAppClientLiveTest.java | 35 ++++ ...ementVCloudVAppTemplateClientLiveTest.java | 35 ++++ ...useDataElementVCloudVDCClientLiveTest.java | 35 ++++ ...ouseDataElementVCloudVmClientLiveTest.java | 39 ++++ .../src/test/resources/log4j.xml | 170 ++++++++++++++++++ 21 files changed, 1120 insertions(+) create mode 100644 sandbox-providers/greenhousedata-element-vcloud/pom.xml create mode 100644 sandbox-providers/greenhousedata-element-vcloud/src/main/java/org/jclouds/greenhousedata/element/vcloud/GreenHouseDataElementVCloudContextBuilder.java create mode 100644 sandbox-providers/greenhousedata-element-vcloud/src/main/java/org/jclouds/greenhousedata/element/vcloud/GreenHouseDataElementVCloudPropertiesBuilder.java create mode 100644 sandbox-providers/greenhousedata-element-vcloud/src/main/java/org/jclouds/greenhousedata/element/vcloud/GreenHouseDataElementVCloudProviderMetadata.java create mode 100644 sandbox-providers/greenhousedata-element-vcloud/src/main/java/org/jclouds/greenhousedata/element/vcloud/config/GreenHouseDataElementVCloudComputeServiceContextModule.java create mode 100644 sandbox-providers/greenhousedata-element-vcloud/src/main/java/org/jclouds/greenhousedata/element/vcloud/config/GreenHouseDataElementVCloudRestClientModule.java create mode 100644 sandbox-providers/greenhousedata-element-vcloud/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata create mode 100644 sandbox-providers/greenhousedata-element-vcloud/src/test/java/org/jclouds/greenhousedata/element/vcloud/DeprecatedGreenHouseDataElementVCloudClientLiveTest.java create mode 100644 sandbox-providers/greenhousedata-element-vcloud/src/test/java/org/jclouds/greenhousedata/element/vcloud/GreenHouseDataElementVCloudProviderTest.java create mode 100644 sandbox-providers/greenhousedata-element-vcloud/src/test/java/org/jclouds/greenhousedata/element/vcloud/compute/GreenHouseDataElementVCloudComputeServiceLiveTest.java create mode 100644 sandbox-providers/greenhousedata-element-vcloud/src/test/java/org/jclouds/greenhousedata/element/vcloud/compute/GreenHouseDataElementVCloudTemplateBuilderLiveTest.java create mode 100644 sandbox-providers/greenhousedata-element-vcloud/src/test/java/org/jclouds/greenhousedata/element/vcloud/features/GreenHouseDataElementVCloudCatalogClientLiveTest.java create mode 100644 sandbox-providers/greenhousedata-element-vcloud/src/test/java/org/jclouds/greenhousedata/element/vcloud/features/GreenHouseDataElementVCloudNetworkClientLiveTest.java create mode 100644 sandbox-providers/greenhousedata-element-vcloud/src/test/java/org/jclouds/greenhousedata/element/vcloud/features/GreenHouseDataElementVCloudOrgClientLiveTest.java create mode 100644 sandbox-providers/greenhousedata-element-vcloud/src/test/java/org/jclouds/greenhousedata/element/vcloud/features/GreenHouseDataElementVCloudTaskClientLiveTest.java create mode 100644 sandbox-providers/greenhousedata-element-vcloud/src/test/java/org/jclouds/greenhousedata/element/vcloud/features/GreenHouseDataElementVCloudVAppClientLiveTest.java create mode 100644 sandbox-providers/greenhousedata-element-vcloud/src/test/java/org/jclouds/greenhousedata/element/vcloud/features/GreenHouseDataElementVCloudVAppTemplateClientLiveTest.java create mode 100644 sandbox-providers/greenhousedata-element-vcloud/src/test/java/org/jclouds/greenhousedata/element/vcloud/features/GreenHouseDataElementVCloudVDCClientLiveTest.java create mode 100644 sandbox-providers/greenhousedata-element-vcloud/src/test/java/org/jclouds/greenhousedata/element/vcloud/features/GreenHouseDataElementVCloudVmClientLiveTest.java create mode 100644 sandbox-providers/greenhousedata-element-vcloud/src/test/resources/log4j.xml diff --git a/core/src/main/resources/rest.properties b/core/src/main/resources/rest.properties index c4167f6770..21fa5249d3 100644 --- a/core/src/main/resources/rest.properties +++ b/core/src/main/resources/rest.properties @@ -107,6 +107,9 @@ bluelock-vcloud-zone01.propertiesbuilder=org.jclouds.bluelock.vcloud.zone01.Blue stratogen-vcloud-mycloud.contextbuilder=org.jclouds.stratogen.vcloud.mycloud.StratoGenVCloudMyCloudContextBuilder stratogen-vcloud-mycloud.propertiesbuilder=org.jclouds.stratogen.vcloud.mycloud.StratoGenVCloudMyCloudPropertiesBuilder +greenhousedata-element-vcloud.contextbuilder=org.jclouds.greenhousedata.element.vcloud.GreenHouseDataElementVCloudContextBuilder +greenhousedata-element-vcloud.propertiesbuilder=org.jclouds.greenhousedata.element.vcloud.GreenHouseDataElementVCloudPropertiesBuilder + gogrid.propertiesbuilder=org.jclouds.gogrid.GoGridPropertiesBuilder gogrid.contextbuilder=org.jclouds.gogrid.GoGridContextBuilder diff --git a/sandbox-providers/greenhousedata-element-vcloud/pom.xml b/sandbox-providers/greenhousedata-element-vcloud/pom.xml new file mode 100644 index 0000000000..7d193bf18f --- /dev/null +++ b/sandbox-providers/greenhousedata-element-vcloud/pom.xml @@ -0,0 +1,164 @@ + + + + + 4.0.0 + + org.jclouds + jclouds-project + 1.1.0-SNAPSHOT + ../../project/pom.xml + + org.jclouds.provider + greenhousedata-element-vcloud + jclouds Green House Data Element vCloud provider + vCloud implementation targeted to Green House Data Element + bundle + + + https://mycloud.greenhousedata.com/api + 1.0 + FIXME_IDENTITY + FIXME_CREDENTIAL + + + + + org.jclouds.api + vcloud + ${project.version} + + + org.jclouds.common + vcloud-common + ${project.version} + test-jar + test + + + org.jclouds.api + vcloud + ${project.version} + test-jar + test + + + org.jclouds + jclouds-core + ${project.version} + test-jar + test + + + org.jclouds + jclouds-compute + ${project.version} + test-jar + test + + + org.jclouds.driver + jclouds-log4j + ${project.version} + test + + + org.jclouds.driver + jclouds-jsch + ${project.version} + test + + + com.jcraft + jsch + test + + + log4j + log4j + 1.2.16 + test + + + + + + live + + + + org.apache.maven.plugins + maven-surefire-plugin + + + integration + integration-test + + test + + + + + test.greenhousedata-element-vcloud.endpoint + ${test.greenhousedata-element-vcloud.endpoint} + + + test.greenhousedata-element-vcloud.apiversion + ${test.greenhousedata-element-vcloud.apiversion} + + + test.greenhousedata-element-vcloud.identity + ${test.greenhousedata-element-vcloud.identity} + + + test.greenhousedata-element-vcloud.credential + ${test.greenhousedata-element-vcloud.credential} + + + + + + + + + + + + + + + org.apache.felix + maven-bundle-plugin + + + ${project.artifactId} + org.jclouds.greenhousedata.element.vcloud.*;version="${project.version}" + org.jclouds.*;version="${project.version}",* + + + + + + + + diff --git a/sandbox-providers/greenhousedata-element-vcloud/src/main/java/org/jclouds/greenhousedata/element/vcloud/GreenHouseDataElementVCloudContextBuilder.java b/sandbox-providers/greenhousedata-element-vcloud/src/main/java/org/jclouds/greenhousedata/element/vcloud/GreenHouseDataElementVCloudContextBuilder.java new file mode 100644 index 0000000000..632826ad8b --- /dev/null +++ b/sandbox-providers/greenhousedata-element-vcloud/src/main/java/org/jclouds/greenhousedata/element/vcloud/GreenHouseDataElementVCloudContextBuilder.java @@ -0,0 +1,51 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.jclouds.greenhousedata.element.vcloud; + +import java.util.List; +import java.util.Properties; + +import org.jclouds.greenhousedata.element.vcloud.config.GreenHouseDataElementVCloudComputeServiceContextModule; +import org.jclouds.greenhousedata.element.vcloud.config.GreenHouseDataElementVCloudRestClientModule; +import org.jclouds.vcloud.VCloudContextBuilder; + +import com.google.inject.Module; + +/** + * {@inheritDoc} + * + * @author Adrian Cole + */ +public class GreenHouseDataElementVCloudContextBuilder extends VCloudContextBuilder { + + public GreenHouseDataElementVCloudContextBuilder(Properties props) { + super(props); + } + + @Override + protected void addContextModule(List modules) { + modules.add(new GreenHouseDataElementVCloudComputeServiceContextModule()); + } + + @Override + protected void addClientModule(List modules) { + modules.add(new GreenHouseDataElementVCloudRestClientModule()); + } + +} diff --git a/sandbox-providers/greenhousedata-element-vcloud/src/main/java/org/jclouds/greenhousedata/element/vcloud/GreenHouseDataElementVCloudPropertiesBuilder.java b/sandbox-providers/greenhousedata-element-vcloud/src/main/java/org/jclouds/greenhousedata/element/vcloud/GreenHouseDataElementVCloudPropertiesBuilder.java new file mode 100644 index 0000000000..f709e70dcd --- /dev/null +++ b/sandbox-providers/greenhousedata-element-vcloud/src/main/java/org/jclouds/greenhousedata/element/vcloud/GreenHouseDataElementVCloudPropertiesBuilder.java @@ -0,0 +1,46 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.jclouds.greenhousedata.element.vcloud; + +import static org.jclouds.Constants.PROPERTY_ENDPOINT; +import static org.jclouds.Constants.PROPERTY_ISO3166_CODES; +import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_DEFAULT_NETWORK; + +import java.util.Properties; + +import org.jclouds.vcloud.VCloudPropertiesBuilder; + +/** + * + * @author Adrian Cole + */ +public class GreenHouseDataElementVCloudPropertiesBuilder extends VCloudPropertiesBuilder { + @Override + protected Properties defaultProperties() { + Properties properties = super.defaultProperties(); + properties.setProperty(PROPERTY_ISO3166_CODES, "US-WY"); + properties.setProperty(PROPERTY_ENDPOINT, "https://mycloud.greenhousedata.com/api"); + properties.setProperty(PROPERTY_VCLOUD_DEFAULT_NETWORK, "orgNet-.*-Internal-Routed"); + return properties; + } + + public GreenHouseDataElementVCloudPropertiesBuilder(Properties properties) { + super(properties); + } +} diff --git a/sandbox-providers/greenhousedata-element-vcloud/src/main/java/org/jclouds/greenhousedata/element/vcloud/GreenHouseDataElementVCloudProviderMetadata.java b/sandbox-providers/greenhousedata-element-vcloud/src/main/java/org/jclouds/greenhousedata/element/vcloud/GreenHouseDataElementVCloudProviderMetadata.java new file mode 100644 index 0000000000..4e3f09fa65 --- /dev/null +++ b/sandbox-providers/greenhousedata-element-vcloud/src/main/java/org/jclouds/greenhousedata/element/vcloud/GreenHouseDataElementVCloudProviderMetadata.java @@ -0,0 +1,116 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.jclouds.greenhousedata.element.vcloud; + +import com.google.common.collect.ImmutableSet; + +import java.net.URI; +import java.util.Set; + +import org.jclouds.providers.BaseProviderMetadata; +import org.jclouds.providers.ProviderMetadata; + +/** + * Implementation of {@link org.jclouds.types.ProviderMetadata} for Green House Data Element vCloud + * + * @author Adrian Cole + */ +public class GreenHouseDataElementVCloudProviderMetadata extends BaseProviderMetadata { + + /** + * {@inheritDoc} + */ + @Override + public String getId() { + return "greenhousedata-element-vcloud"; + } + + /** + * {@inheritDoc} + */ + @Override + public String getType() { + return ProviderMetadata.COMPUTE_TYPE; + } + + /** + * {@inheritDoc} + */ + @Override + public String getName() { + return "Green House Data Element vCloud"; + } + + /** + * {@inheritDoc} + */ + @Override + public String getIdentityName() { + return "User at Organization (user@org)"; + } + + /** + * {@inheritDoc} + */ + @Override + public String getCredentialName() { + return "Password"; + } + + /** + * {@inheritDoc} + */ + @Override + public URI getHomepage() { + return URI.create("http://www.greenhousedata.com/element-cloud-hosting/vcloud-services/"); + } + + /** + * {@inheritDoc} + */ + @Override + public URI getConsole() { + return URI.create("https://mycloud.greenhousedata.com/cloud/"); + } + + /** + * {@inheritDoc} + */ + @Override + public URI getApiDocumentation() { + return URI.create("http://www.greenhousedata.com/element-cloud-hosting/vcloud-services/"); + } + + /** + * {@inheritDoc} + */ + @Override + public Set getLinkedServices() { + return ImmutableSet.of("greenhousedata-element-vcloud"); + } + + /** + * {@inheritDoc} + */ + @Override + public Set getIso3166Codes() { + return ImmutableSet.of("US-WY"); + } + +} diff --git a/sandbox-providers/greenhousedata-element-vcloud/src/main/java/org/jclouds/greenhousedata/element/vcloud/config/GreenHouseDataElementVCloudComputeServiceContextModule.java b/sandbox-providers/greenhousedata-element-vcloud/src/main/java/org/jclouds/greenhousedata/element/vcloud/config/GreenHouseDataElementVCloudComputeServiceContextModule.java new file mode 100644 index 0000000000..495d018c5e --- /dev/null +++ b/sandbox-providers/greenhousedata-element-vcloud/src/main/java/org/jclouds/greenhousedata/element/vcloud/config/GreenHouseDataElementVCloudComputeServiceContextModule.java @@ -0,0 +1,39 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.jclouds.greenhousedata.element.vcloud.config; + +import org.jclouds.compute.domain.OsFamily; +import org.jclouds.compute.domain.TemplateBuilder; +import org.jclouds.vcloud.compute.config.VCloudComputeServiceContextModule; + +import com.google.inject.Injector; + +/** + * per docs, we are to use pool mode. + * + * @author Adrian Cole + */ +public class GreenHouseDataElementVCloudComputeServiceContextModule extends VCloudComputeServiceContextModule { + + //CentOS template matches Linux incorrectly + @Override + protected TemplateBuilder provideTemplate(Injector injector, TemplateBuilder template) { + return template.osFamily(OsFamily.LINUX); + } +} diff --git a/sandbox-providers/greenhousedata-element-vcloud/src/main/java/org/jclouds/greenhousedata/element/vcloud/config/GreenHouseDataElementVCloudRestClientModule.java b/sandbox-providers/greenhousedata-element-vcloud/src/main/java/org/jclouds/greenhousedata/element/vcloud/config/GreenHouseDataElementVCloudRestClientModule.java new file mode 100644 index 0000000000..1f40ae3270 --- /dev/null +++ b/sandbox-providers/greenhousedata-element-vcloud/src/main/java/org/jclouds/greenhousedata/element/vcloud/config/GreenHouseDataElementVCloudRestClientModule.java @@ -0,0 +1,34 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.jclouds.greenhousedata.element.vcloud.config; + +import org.jclouds.http.RequiresHttp; +import org.jclouds.rest.ConfiguresRestClient; +import org.jclouds.vcloud.config.VCloudRestClientModule; + +/** + * Configures the VCloud authentication service connection, including logging and http transport. + * + * @author Adrian Cole + */ +@RequiresHttp +@ConfiguresRestClient +public class GreenHouseDataElementVCloudRestClientModule extends VCloudRestClientModule { + +} diff --git a/sandbox-providers/greenhousedata-element-vcloud/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata b/sandbox-providers/greenhousedata-element-vcloud/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata new file mode 100644 index 0000000000..84a4ce28d1 --- /dev/null +++ b/sandbox-providers/greenhousedata-element-vcloud/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata @@ -0,0 +1 @@ +org.jclouds.greenhousedata.element.vcloud.GreenHouseDataElementVCloudProviderMetadata diff --git a/sandbox-providers/greenhousedata-element-vcloud/src/test/java/org/jclouds/greenhousedata/element/vcloud/DeprecatedGreenHouseDataElementVCloudClientLiveTest.java b/sandbox-providers/greenhousedata-element-vcloud/src/test/java/org/jclouds/greenhousedata/element/vcloud/DeprecatedGreenHouseDataElementVCloudClientLiveTest.java new file mode 100644 index 0000000000..65d601f6f2 --- /dev/null +++ b/sandbox-providers/greenhousedata-element-vcloud/src/test/java/org/jclouds/greenhousedata/element/vcloud/DeprecatedGreenHouseDataElementVCloudClientLiveTest.java @@ -0,0 +1,35 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.jclouds.greenhousedata.element.vcloud; + +import org.jclouds.vcloud.DeprecatedVCloudClientLiveTest; +import org.testng.annotations.Test; + +/** + * + * @author Adrian Cole + */ +@Deprecated +@Test(groups = "live", singleThreaded = true, testName = "DeprecatedGreenHouseDataElementVCloudClientLiveTest") +public class DeprecatedGreenHouseDataElementVCloudClientLiveTest extends DeprecatedVCloudClientLiveTest { + public DeprecatedGreenHouseDataElementVCloudClientLiveTest() { + provider = "greenhousedata-element-vcloud"; + } + +} diff --git a/sandbox-providers/greenhousedata-element-vcloud/src/test/java/org/jclouds/greenhousedata/element/vcloud/GreenHouseDataElementVCloudProviderTest.java b/sandbox-providers/greenhousedata-element-vcloud/src/test/java/org/jclouds/greenhousedata/element/vcloud/GreenHouseDataElementVCloudProviderTest.java new file mode 100644 index 0000000000..6a43fc95d6 --- /dev/null +++ b/sandbox-providers/greenhousedata-element-vcloud/src/test/java/org/jclouds/greenhousedata/element/vcloud/GreenHouseDataElementVCloudProviderTest.java @@ -0,0 +1,35 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.jclouds.greenhousedata.element.vcloud; + +import org.jclouds.providers.BaseProviderMetadataTest; +import org.jclouds.providers.ProviderMetadata; +import org.testng.annotations.Test; + +/** + * + * @author Adrian Cole + */ +@Test(groups = "unit", testName = "GreenHouseDataElementVCloudProviderTest") +public class GreenHouseDataElementVCloudProviderTest extends BaseProviderMetadataTest { + + public GreenHouseDataElementVCloudProviderTest() { + super(new GreenHouseDataElementVCloudProviderMetadata(), ProviderMetadata.COMPUTE_TYPE); + } +} diff --git a/sandbox-providers/greenhousedata-element-vcloud/src/test/java/org/jclouds/greenhousedata/element/vcloud/compute/GreenHouseDataElementVCloudComputeServiceLiveTest.java b/sandbox-providers/greenhousedata-element-vcloud/src/test/java/org/jclouds/greenhousedata/element/vcloud/compute/GreenHouseDataElementVCloudComputeServiceLiveTest.java new file mode 100644 index 0000000000..41eab617cb --- /dev/null +++ b/sandbox-providers/greenhousedata-element-vcloud/src/test/java/org/jclouds/greenhousedata/element/vcloud/compute/GreenHouseDataElementVCloudComputeServiceLiveTest.java @@ -0,0 +1,70 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.jclouds.greenhousedata.element.vcloud.compute; + +import static org.jclouds.compute.util.ComputeServiceUtils.getCores; +import static org.testng.Assert.assertEquals; + +import org.jclouds.compute.domain.Image; +import org.jclouds.compute.domain.OsFamily; +import org.jclouds.compute.domain.Template; +import org.jclouds.compute.domain.TemplateBuilder; +import org.jclouds.compute.predicates.OperatingSystemPredicates; +import org.jclouds.vcloud.compute.VCloudComputeServiceLiveTest; +import org.testng.annotations.Test; + +/** + * + * + * @author Adrian Cole + */ +@Test(groups = "live", enabled = true, singleThreaded = true, testName = "GreenHouseDataElementVCloudComputeServiceLiveTest") +public class GreenHouseDataElementVCloudComputeServiceLiveTest extends VCloudComputeServiceLiveTest { + public GreenHouseDataElementVCloudComputeServiceLiveTest() { + provider = "greenhousedata-element-vcloud"; + // vcloud requires instantiate before deploy, which takes longer than 30 seconds + nonBlockDurationSeconds = 300; + } + + @Override + public void setServiceDefaults() { + group = "director"; + } + + @Test + public void testTemplateBuilder() { + Template defaultTemplate = client.templateBuilder().build(); + assertEquals(defaultTemplate.getImage().getOperatingSystem().is64Bit(), true); + assert OperatingSystemPredicates.supportsApt().apply(defaultTemplate.getImage().getOperatingSystem()); + assertEquals(defaultTemplate.getImage().getOperatingSystem().getFamily(), OsFamily.UBUNTU); + assertEquals(defaultTemplate.getImage().getOperatingSystem().getDescription(), "Ubuntu Linux (64-bit)"); + assert defaultTemplate.getLocation().getId() != null : defaultTemplate.getLocation(); + assertEquals(getCores(defaultTemplate.getHardware()), 1.0d); + System.out.println(defaultTemplate.getHardware()); + } + + @Override + protected Template buildTemplate(TemplateBuilder templateBuilder) { + Template template = super.buildTemplate(templateBuilder); + Image image = template.getImage(); + assert image.getDefaultCredentials().credential != null : image; + return template; + } + +} diff --git a/sandbox-providers/greenhousedata-element-vcloud/src/test/java/org/jclouds/greenhousedata/element/vcloud/compute/GreenHouseDataElementVCloudTemplateBuilderLiveTest.java b/sandbox-providers/greenhousedata-element-vcloud/src/test/java/org/jclouds/greenhousedata/element/vcloud/compute/GreenHouseDataElementVCloudTemplateBuilderLiveTest.java new file mode 100644 index 0000000000..8de5f13d76 --- /dev/null +++ b/sandbox-providers/greenhousedata-element-vcloud/src/test/java/org/jclouds/greenhousedata/element/vcloud/compute/GreenHouseDataElementVCloudTemplateBuilderLiveTest.java @@ -0,0 +1,72 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.jclouds.greenhousedata.element.vcloud.compute; + +import static org.jclouds.compute.util.ComputeServiceUtils.getCores; +import static org.testng.Assert.assertEquals; + +import java.io.IOException; +import java.util.Set; + +import org.jclouds.compute.BaseTemplateBuilderLiveTest; +import org.jclouds.compute.domain.OsFamily; +import org.jclouds.compute.domain.OsFamilyVersion64Bit; +import org.jclouds.compute.domain.Template; +import org.testng.annotations.Test; + +import com.google.common.base.Predicate; +import com.google.common.collect.ImmutableSet; + +/** + * + * @author Adrian Cole + */ +@Test(groups = "live", testName = "GreenHouseDataElementVCloudTemplateBuilderLiveTest") +public class GreenHouseDataElementVCloudTemplateBuilderLiveTest extends BaseTemplateBuilderLiveTest { + + public GreenHouseDataElementVCloudTemplateBuilderLiveTest() { + provider = "greenhousedata-element-vcloud"; + } + + @Override + protected Predicate defineUnsupportedOperatingSystems() { + return new Predicate() { + + @Override + public boolean apply(OsFamilyVersion64Bit input) { + return true; + } + + }; + } + + @Override + public void testDefaultTemplateBuilder() throws IOException { + Template defaultTemplate = context.getComputeService().templateBuilder().build(); + assertEquals(defaultTemplate.getImage().getOperatingSystem().getVersion(), ""); + assertEquals(defaultTemplate.getImage().getOperatingSystem().is64Bit(), true); + assertEquals(defaultTemplate.getImage().getOperatingSystem().getFamily(), OsFamily.LINUX); + assertEquals(getCores(defaultTemplate.getHardware()), 2.0d); + } + + @Override + protected Set getIso3166Codes() { + return ImmutableSet. of("US-WY"); + } +} diff --git a/sandbox-providers/greenhousedata-element-vcloud/src/test/java/org/jclouds/greenhousedata/element/vcloud/features/GreenHouseDataElementVCloudCatalogClientLiveTest.java b/sandbox-providers/greenhousedata-element-vcloud/src/test/java/org/jclouds/greenhousedata/element/vcloud/features/GreenHouseDataElementVCloudCatalogClientLiveTest.java new file mode 100644 index 0000000000..6d071f7f5c --- /dev/null +++ b/sandbox-providers/greenhousedata-element-vcloud/src/test/java/org/jclouds/greenhousedata/element/vcloud/features/GreenHouseDataElementVCloudCatalogClientLiveTest.java @@ -0,0 +1,35 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.jclouds.greenhousedata.element.vcloud.features; + +import org.jclouds.vcloud.features.CatalogClientLiveTest; +import org.testng.annotations.Test; + +/** + * + * + * @author Adrian Cole + */ +@Test(groups = "live", enabled = true, singleThreaded = true, testName = "GreenHouseDataElementVCloudCatalogClientLiveTest") +public class GreenHouseDataElementVCloudCatalogClientLiveTest extends CatalogClientLiveTest { + + public GreenHouseDataElementVCloudCatalogClientLiveTest() { + provider = "greenhousedata-element-vcloud"; + } +} diff --git a/sandbox-providers/greenhousedata-element-vcloud/src/test/java/org/jclouds/greenhousedata/element/vcloud/features/GreenHouseDataElementVCloudNetworkClientLiveTest.java b/sandbox-providers/greenhousedata-element-vcloud/src/test/java/org/jclouds/greenhousedata/element/vcloud/features/GreenHouseDataElementVCloudNetworkClientLiveTest.java new file mode 100644 index 0000000000..2f354c34ee --- /dev/null +++ b/sandbox-providers/greenhousedata-element-vcloud/src/test/java/org/jclouds/greenhousedata/element/vcloud/features/GreenHouseDataElementVCloudNetworkClientLiveTest.java @@ -0,0 +1,35 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.jclouds.greenhousedata.element.vcloud.features; + +import org.jclouds.vcloud.features.NetworkClientLiveTest; +import org.testng.annotations.Test; + +/** + * + * + * @author Adrian Cole + */ +@Test(groups = "live", enabled = true, singleThreaded = true, testName = "GreenHouseDataElementVCloudNetworkClientLiveTest") +public class GreenHouseDataElementVCloudNetworkClientLiveTest extends NetworkClientLiveTest { + + public GreenHouseDataElementVCloudNetworkClientLiveTest() { + provider = "greenhousedata-element-vcloud"; + } +} diff --git a/sandbox-providers/greenhousedata-element-vcloud/src/test/java/org/jclouds/greenhousedata/element/vcloud/features/GreenHouseDataElementVCloudOrgClientLiveTest.java b/sandbox-providers/greenhousedata-element-vcloud/src/test/java/org/jclouds/greenhousedata/element/vcloud/features/GreenHouseDataElementVCloudOrgClientLiveTest.java new file mode 100644 index 0000000000..02ab0fb483 --- /dev/null +++ b/sandbox-providers/greenhousedata-element-vcloud/src/test/java/org/jclouds/greenhousedata/element/vcloud/features/GreenHouseDataElementVCloudOrgClientLiveTest.java @@ -0,0 +1,35 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.jclouds.greenhousedata.element.vcloud.features; + +import org.jclouds.vcloud.features.OrgClientLiveTest; +import org.testng.annotations.Test; + +/** + * + * + * @author Adrian Cole + */ +@Test(groups = "live", enabled = true, singleThreaded = true, testName = "GreenHouseDataElementVCloudOrgClientLiveTest") +public class GreenHouseDataElementVCloudOrgClientLiveTest extends OrgClientLiveTest { + + public GreenHouseDataElementVCloudOrgClientLiveTest() { + provider = "greenhousedata-element-vcloud"; + } +} diff --git a/sandbox-providers/greenhousedata-element-vcloud/src/test/java/org/jclouds/greenhousedata/element/vcloud/features/GreenHouseDataElementVCloudTaskClientLiveTest.java b/sandbox-providers/greenhousedata-element-vcloud/src/test/java/org/jclouds/greenhousedata/element/vcloud/features/GreenHouseDataElementVCloudTaskClientLiveTest.java new file mode 100644 index 0000000000..23e83fd1c4 --- /dev/null +++ b/sandbox-providers/greenhousedata-element-vcloud/src/test/java/org/jclouds/greenhousedata/element/vcloud/features/GreenHouseDataElementVCloudTaskClientLiveTest.java @@ -0,0 +1,35 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.jclouds.greenhousedata.element.vcloud.features; + +import org.jclouds.vcloud.features.TaskClientLiveTest; +import org.testng.annotations.Test; + +/** + * + * + * @author Adrian Cole + */ +@Test(groups = "live", enabled = true, singleThreaded = true, testName = "GreenHouseDataElementVCloudTaskClientLiveTest") +public class GreenHouseDataElementVCloudTaskClientLiveTest extends TaskClientLiveTest { + + public GreenHouseDataElementVCloudTaskClientLiveTest() { + provider = "greenhousedata-element-vcloud"; + } +} diff --git a/sandbox-providers/greenhousedata-element-vcloud/src/test/java/org/jclouds/greenhousedata/element/vcloud/features/GreenHouseDataElementVCloudVAppClientLiveTest.java b/sandbox-providers/greenhousedata-element-vcloud/src/test/java/org/jclouds/greenhousedata/element/vcloud/features/GreenHouseDataElementVCloudVAppClientLiveTest.java new file mode 100644 index 0000000000..07ed4db972 --- /dev/null +++ b/sandbox-providers/greenhousedata-element-vcloud/src/test/java/org/jclouds/greenhousedata/element/vcloud/features/GreenHouseDataElementVCloudVAppClientLiveTest.java @@ -0,0 +1,35 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.jclouds.greenhousedata.element.vcloud.features; + +import org.jclouds.vcloud.features.VAppClientLiveTest; +import org.testng.annotations.Test; + +/** + * + * + * @author Adrian Cole + */ +@Test(groups = "live", enabled = true, singleThreaded = true, testName = "GreenHouseDataElementVCloudVAppClientLiveTest") +public class GreenHouseDataElementVCloudVAppClientLiveTest extends VAppClientLiveTest { + + public GreenHouseDataElementVCloudVAppClientLiveTest() { + provider = "greenhousedata-element-vcloud"; + } +} diff --git a/sandbox-providers/greenhousedata-element-vcloud/src/test/java/org/jclouds/greenhousedata/element/vcloud/features/GreenHouseDataElementVCloudVAppTemplateClientLiveTest.java b/sandbox-providers/greenhousedata-element-vcloud/src/test/java/org/jclouds/greenhousedata/element/vcloud/features/GreenHouseDataElementVCloudVAppTemplateClientLiveTest.java new file mode 100644 index 0000000000..c164abe3f0 --- /dev/null +++ b/sandbox-providers/greenhousedata-element-vcloud/src/test/java/org/jclouds/greenhousedata/element/vcloud/features/GreenHouseDataElementVCloudVAppTemplateClientLiveTest.java @@ -0,0 +1,35 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.jclouds.greenhousedata.element.vcloud.features; + +import org.jclouds.vcloud.features.VAppTemplateClientLiveTest; +import org.testng.annotations.Test; + +/** + * + * + * @author Adrian Cole + */ +@Test(groups = "live", enabled = true, singleThreaded = true, testName = "GreenHouseDataElementVCloudVAppTemplateClientLiveTest") +public class GreenHouseDataElementVCloudVAppTemplateClientLiveTest extends VAppTemplateClientLiveTest { + + public GreenHouseDataElementVCloudVAppTemplateClientLiveTest() { + provider = "greenhousedata-element-vcloud"; + } +} diff --git a/sandbox-providers/greenhousedata-element-vcloud/src/test/java/org/jclouds/greenhousedata/element/vcloud/features/GreenHouseDataElementVCloudVDCClientLiveTest.java b/sandbox-providers/greenhousedata-element-vcloud/src/test/java/org/jclouds/greenhousedata/element/vcloud/features/GreenHouseDataElementVCloudVDCClientLiveTest.java new file mode 100644 index 0000000000..fe4f9dbe70 --- /dev/null +++ b/sandbox-providers/greenhousedata-element-vcloud/src/test/java/org/jclouds/greenhousedata/element/vcloud/features/GreenHouseDataElementVCloudVDCClientLiveTest.java @@ -0,0 +1,35 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.jclouds.greenhousedata.element.vcloud.features; + +import org.jclouds.vcloud.features.VDCClientLiveTest; +import org.testng.annotations.Test; + +/** + * + * + * @author Adrian Cole + */ +@Test(groups = "live", enabled = true, singleThreaded = true, testName = "GreenHouseDataElementVCloudVDCClientLiveTest") +public class GreenHouseDataElementVCloudVDCClientLiveTest extends VDCClientLiveTest { + + public GreenHouseDataElementVCloudVDCClientLiveTest() { + provider = "greenhousedata-element-vcloud"; + } +} diff --git a/sandbox-providers/greenhousedata-element-vcloud/src/test/java/org/jclouds/greenhousedata/element/vcloud/features/GreenHouseDataElementVCloudVmClientLiveTest.java b/sandbox-providers/greenhousedata-element-vcloud/src/test/java/org/jclouds/greenhousedata/element/vcloud/features/GreenHouseDataElementVCloudVmClientLiveTest.java new file mode 100644 index 0000000000..736e6b0902 --- /dev/null +++ b/sandbox-providers/greenhousedata-element-vcloud/src/test/java/org/jclouds/greenhousedata/element/vcloud/features/GreenHouseDataElementVCloudVmClientLiveTest.java @@ -0,0 +1,39 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.jclouds.greenhousedata.element.vcloud.features; + +import org.jclouds.vcloud.features.VmClientLiveTest; +import org.testng.annotations.Test; + +/** + * + * + * @author Adrian Cole + */ +@Test(groups = "live", enabled = true, singleThreaded = true, testName = "GreenHouseDataElementVCloudVmClientLiveTest") +public class GreenHouseDataElementVCloudVmClientLiveTest extends VmClientLiveTest { + + public GreenHouseDataElementVCloudVmClientLiveTest() { + provider = "greenhousedata-element-vcloud"; + } + + protected void checkApiOutput(String apiOutput) { + checkApiOutput1_0_0(apiOutput); + } +} diff --git a/sandbox-providers/greenhousedata-element-vcloud/src/test/resources/log4j.xml b/sandbox-providers/greenhousedata-element-vcloud/src/test/resources/log4j.xml new file mode 100644 index 0000000000..c1e74e57ff --- /dev/null +++ b/sandbox-providers/greenhousedata-element-vcloud/src/test/resources/log4j.xml @@ -0,0 +1,170 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From b468d3b04785f37be605f328c64233b9e14cc590 Mon Sep 17 00:00:00 2001 From: Adrian Cole Date: Tue, 28 Jun 2011 11:43:27 -0700 Subject: [PATCH 073/264] Issue 608: investigate template where EC2 AZ is specified explicitly --- .../aws/ec2/compute/AWSEC2TemplateBuilderLiveTest.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/compute/AWSEC2TemplateBuilderLiveTest.java b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/compute/AWSEC2TemplateBuilderLiveTest.java index 57126d25fe..424904984b 100644 --- a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/compute/AWSEC2TemplateBuilderLiveTest.java +++ b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/compute/AWSEC2TemplateBuilderLiveTest.java @@ -95,10 +95,10 @@ public class AWSEC2TemplateBuilderLiveTest extends BaseTemplateBuilderLiveTest { } @Test - public void testTemplateBuilderCanUseImageIdAndhardwareId() { + public void testTemplateBuilderCanUseImageIdAndhardwareIdAndAZ() { Template template = context.getComputeService().templateBuilder().imageId("us-east-1/ami-ccb35ea5").hardwareId( - InstanceType.M2_2XLARGE).build(); + InstanceType.M2_2XLARGE).locationId("us-east-1a").build(); System.out.println(template.getHardware()); assert (template.getImage().getProviderId().startsWith("ami-")) : template; @@ -107,7 +107,7 @@ public class AWSEC2TemplateBuilderLiveTest extends BaseTemplateBuilderLiveTest { assertEquals(template.getImage().getOperatingSystem().getFamily(), OsFamily.CENTOS); assertEquals(template.getImage().getVersion(), "4.4.10"); assertEquals(template.getImage().getUserMetadata().get("rootDeviceType"), "instance-store"); - assertEquals(template.getLocation().getId(), "us-east-1"); + assertEquals(template.getLocation().getId(), "us-east-1a"); assertEquals(getCores(template.getHardware()), 4.0d); assertEquals(template.getHardware().getId(), InstanceType.M2_2XLARGE); assertEquals(template.getImage().getOperatingSystem().getArch(), "paravirtual"); From 750be3137d745926eb5bb7732b2cd749b93ad535 Mon Sep 17 00:00:00 2001 From: Adrian Cole Date: Tue, 28 Jun 2011 11:46:16 -0700 Subject: [PATCH 074/264] Issue 608: investigate template where EC2 AZ is specified explicitly leaves ami with correct region code --- .../jclouds/aws/ec2/compute/AWSEC2TemplateBuilderLiveTest.java | 1 + 1 file changed, 1 insertion(+) diff --git a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/compute/AWSEC2TemplateBuilderLiveTest.java b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/compute/AWSEC2TemplateBuilderLiveTest.java index 424904984b..be8f681da1 100644 --- a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/compute/AWSEC2TemplateBuilderLiveTest.java +++ b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/compute/AWSEC2TemplateBuilderLiveTest.java @@ -108,6 +108,7 @@ public class AWSEC2TemplateBuilderLiveTest extends BaseTemplateBuilderLiveTest { assertEquals(template.getImage().getVersion(), "4.4.10"); assertEquals(template.getImage().getUserMetadata().get("rootDeviceType"), "instance-store"); assertEquals(template.getLocation().getId(), "us-east-1a"); + assertEquals(template.getImage().getLocation().getId(), "us-east-1"); assertEquals(getCores(template.getHardware()), 4.0d); assertEquals(template.getHardware().getId(), InstanceType.M2_2XLARGE); assertEquals(template.getImage().getOperatingSystem().getArch(), "paravirtual"); From 3c8297ac77d53eeaa41577ff61dec32fc555e53e Mon Sep 17 00:00:00 2001 From: Andrew Phillips Date: Tue, 28 Jun 2011 17:14:21 -0400 Subject: [PATCH 075/264] Removed an unnecessary config property (was the same as the default) --- project/pom.xml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/project/pom.xml b/project/pom.xml index 7c5c2d5fa1..f294f49910 100644 --- a/project/pom.xml +++ b/project/pom.xml @@ -751,9 +751,6 @@ pageTracker._trackPageview(); maven-jxr-plugin 2.2 - - ${project.build.sourceEncoding} - maven-project-info-reports-plugin @@ -880,9 +877,6 @@ pageTracker._trackPageview(); maven-jxr-plugin 2.2 - - ${project.build.sourceEncoding} - maven-surefire-report-plugin From cc49951404c02476663c04295cf51056c796c88c Mon Sep 17 00:00:00 2001 From: Adrian Cole Date: Tue, 28 Jun 2011 18:11:00 -0700 Subject: [PATCH 076/264] updated demos to new jclouds version --- demos/pom.xml | 2 +- demos/tweetstore/gae-tweetstore-spring/pom.xml | 2 +- demos/tweetstore/gae-tweetstore/pom.xml | 2 +- demos/tweetstore/pom.xml | 2 +- demos/tweetstore/runatcloud-tweetstore/pom.xml | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/demos/pom.xml b/demos/pom.xml index 2051a2c1dc..1614fb7053 100644 --- a/demos/pom.xml +++ b/demos/pom.xml @@ -24,7 +24,7 @@ jclouds-project org.jclouds - 1.0-SNAPSHOT + 1.1.0-SNAPSHOT ../project/pom.xml 4.0.0 diff --git a/demos/tweetstore/gae-tweetstore-spring/pom.xml b/demos/tweetstore/gae-tweetstore-spring/pom.xml index 7098814889..985b50c87f 100644 --- a/demos/tweetstore/gae-tweetstore-spring/pom.xml +++ b/demos/tweetstore/gae-tweetstore-spring/pom.xml @@ -25,7 +25,7 @@ org.jclouds jclouds-demos-tweetstore-project - 1.0-SNAPSHOT + 1.1.0-SNAPSHOT jclouds-demo-gae-tweetstore-spring war diff --git a/demos/tweetstore/gae-tweetstore/pom.xml b/demos/tweetstore/gae-tweetstore/pom.xml index 142189e77b..722b1e4150 100644 --- a/demos/tweetstore/gae-tweetstore/pom.xml +++ b/demos/tweetstore/gae-tweetstore/pom.xml @@ -23,7 +23,7 @@ org.jclouds jclouds-demos-tweetstore-project - 1.0-SNAPSHOT + 1.1.0-SNAPSHOT jclouds-demo-gae-tweetstore war diff --git a/demos/tweetstore/pom.xml b/demos/tweetstore/pom.xml index 114e7d2955..45c995ba22 100644 --- a/demos/tweetstore/pom.xml +++ b/demos/tweetstore/pom.xml @@ -24,7 +24,7 @@ jclouds-demos-project org.jclouds - 1.0-SNAPSHOT + 1.1.0-SNAPSHOT 4.0.0 jclouds-demos-tweetstore-project diff --git a/demos/tweetstore/runatcloud-tweetstore/pom.xml b/demos/tweetstore/runatcloud-tweetstore/pom.xml index 0a2031c9dc..ff17d3f664 100644 --- a/demos/tweetstore/runatcloud-tweetstore/pom.xml +++ b/demos/tweetstore/runatcloud-tweetstore/pom.xml @@ -23,7 +23,7 @@ org.jclouds jclouds-demos-tweetstore-project - 1.0-SNAPSHOT + 1.1.0-SNAPSHOT jclouds-demo-runatcloud-tweetstore war From 4d45cd19e5fc254f083d53d6dab09cd19c0923e3 Mon Sep 17 00:00:00 2001 From: Adrian Cole Date: Tue, 28 Jun 2011 18:17:52 -0700 Subject: [PATCH 077/264] fixed repo in cloudbees demo --- demos/tweetstore/runatcloud-tweetstore/pom.xml | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/demos/tweetstore/runatcloud-tweetstore/pom.xml b/demos/tweetstore/runatcloud-tweetstore/pom.xml index ff17d3f664..09d96030e9 100644 --- a/demos/tweetstore/runatcloud-tweetstore/pom.xml +++ b/demos/tweetstore/runatcloud-tweetstore/pom.xml @@ -38,6 +38,19 @@ jclouds-tweetstore-runatcloud + + + bees-plugins-snapshots + http://repository-cloudbees.forge.cloudbees.com/public-snapshot + + false + + + true + + + + com.google.inject.extensions From d122e0e77bddd118be9afb71b1d077fcd0038b49 Mon Sep 17 00:00:00 2001 From: Andrew Phillips Date: Tue, 28 Jun 2011 21:05:01 -0400 Subject: [PATCH 078/264] Added a repository to locate net.stax:stax-appserver for runatcloud-tweetstore --- demos/tweetstore/runatcloud-tweetstore/pom.xml | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/demos/tweetstore/runatcloud-tweetstore/pom.xml b/demos/tweetstore/runatcloud-tweetstore/pom.xml index 09d96030e9..6330ba619a 100644 --- a/demos/tweetstore/runatcloud-tweetstore/pom.xml +++ b/demos/tweetstore/runatcloud-tweetstore/pom.xml @@ -107,6 +107,20 @@ + + + + + bees-snapshots + http://repository-cloudbees.forge.cloudbees.com/public-snapshot + + false + + + true + + + @@ -209,7 +223,7 @@ - bees-plugins-snapshots + bees-snapshots http://repository-cloudbees.forge.cloudbees.com/public-snapshot false From ef39cdcd20f973ad24c541eb90aad37e2175cdb6 Mon Sep 17 00:00:00 2001 From: Andrew Phillips Date: Tue, 28 Jun 2011 22:12:47 -0400 Subject: [PATCH 079/264] Removed a duplicate entry that was included by a slightly-too-successful merge --- demos/tweetstore/runatcloud-tweetstore/pom.xml | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/demos/tweetstore/runatcloud-tweetstore/pom.xml b/demos/tweetstore/runatcloud-tweetstore/pom.xml index 6330ba619a..027f9a41ca 100644 --- a/demos/tweetstore/runatcloud-tweetstore/pom.xml +++ b/demos/tweetstore/runatcloud-tweetstore/pom.xml @@ -38,19 +38,6 @@ jclouds-tweetstore-runatcloud - - - bees-plugins-snapshots - http://repository-cloudbees.forge.cloudbees.com/public-snapshot - - false - - - true - - - - com.google.inject.extensions From 5d8dfea9bd10b9419f28bf01d976cf45f711fca7 Mon Sep 17 00:00:00 2001 From: Andrew Phillips Date: Wed, 29 Jun 2011 08:45:30 -0400 Subject: [PATCH 080/264] Added the cloudonestorage provider as a dependency --- demos/tweetstore/runatcloud-tweetstore/pom.xml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/demos/tweetstore/runatcloud-tweetstore/pom.xml b/demos/tweetstore/runatcloud-tweetstore/pom.xml index 027f9a41ca..c99f4c45c6 100644 --- a/demos/tweetstore/runatcloud-tweetstore/pom.xml +++ b/demos/tweetstore/runatcloud-tweetstore/pom.xml @@ -44,6 +44,12 @@ guice-servlet 3.0 + + org.jclouds.provider + cloudonestorage + ${project.version} + runtime + From 4aa9bcb82eac78a14175dfe8e04bda21ae13e421 Mon Sep 17 00:00:00 2001 From: Andrew Phillips Date: Wed, 29 Jun 2011 22:53:45 -0400 Subject: [PATCH 081/264] ObjectFields is only used in tests --- .../tweetstore/integration/StaxSdkAppServer2.java | 11 +++++++++-- .../tweetstore/integration}/utils/ObjectFields.java | 2 +- 2 files changed, 10 insertions(+), 3 deletions(-) rename demos/tweetstore/runatcloud-tweetstore/src/{main/java/org/jclouds/demo/tweetstore/config => test/java/org/jclouds/demo/tweetstore/integration}/utils/ObjectFields.java (97%) diff --git a/demos/tweetstore/runatcloud-tweetstore/src/test/java/org/jclouds/demo/tweetstore/integration/StaxSdkAppServer2.java b/demos/tweetstore/runatcloud-tweetstore/src/test/java/org/jclouds/demo/tweetstore/integration/StaxSdkAppServer2.java index 3d196a79a4..0298d0d92b 100644 --- a/demos/tweetstore/runatcloud-tweetstore/src/test/java/org/jclouds/demo/tweetstore/integration/StaxSdkAppServer2.java +++ b/demos/tweetstore/runatcloud-tweetstore/src/test/java/org/jclouds/demo/tweetstore/integration/StaxSdkAppServer2.java @@ -22,8 +22,8 @@ package org.jclouds.demo.tweetstore.integration; import static com.google.common.base.Predicates.instanceOf; import static java.util.Arrays.asList; -import static org.jclouds.demo.tweetstore.config.utils.ObjectFields.set; -import static org.jclouds.demo.tweetstore.config.utils.ObjectFields.valueOf; +import static org.jclouds.demo.tweetstore.integration.utils.ObjectFields.set; +import static org.jclouds.demo.tweetstore.integration.utils.ObjectFields.valueOf; import java.io.File; import java.io.IOException; @@ -107,6 +107,13 @@ class StaxSdkAppServer2 { serverThread.interrupt(); StaxReflect.getStaxAppQueryTimer(server).cancel(); KillerCallback requestMonitorAssassin = new KillerCallback(StaxReflect.getRequestMonitorTimerCallback(server)); + /* + * Hoping for the best here in terms of visibility - we're setting a variable in a + * different thread which isn't guaranteed to see the change. + * But we can't set the callbackClient before serverThread starts (which would create + * a happens-before relationship) because the objects on which the callbackClient is + * set have not been created yet at that point. + */ set("callbackClient", StaxReflect.getRequestMonitorTimer(server), requestMonitorAssassin); requestMonitorAssassin.setToKill(); } diff --git a/demos/tweetstore/runatcloud-tweetstore/src/main/java/org/jclouds/demo/tweetstore/config/utils/ObjectFields.java b/demos/tweetstore/runatcloud-tweetstore/src/test/java/org/jclouds/demo/tweetstore/integration/utils/ObjectFields.java similarity index 97% rename from demos/tweetstore/runatcloud-tweetstore/src/main/java/org/jclouds/demo/tweetstore/config/utils/ObjectFields.java rename to demos/tweetstore/runatcloud-tweetstore/src/test/java/org/jclouds/demo/tweetstore/integration/utils/ObjectFields.java index 57f857463c..e6c108ab3f 100644 --- a/demos/tweetstore/runatcloud-tweetstore/src/main/java/org/jclouds/demo/tweetstore/config/utils/ObjectFields.java +++ b/demos/tweetstore/runatcloud-tweetstore/src/test/java/org/jclouds/demo/tweetstore/integration/utils/ObjectFields.java @@ -18,7 +18,7 @@ * limitations under the License. * ==================================================================== */ -package org.jclouds.demo.tweetstore.config.utils; +package org.jclouds.demo.tweetstore.integration.utils; import java.lang.reflect.Field; From 0448fcaa9f7552f23756b0e118b0e7220c748c38 Mon Sep 17 00:00:00 2001 From: Andrew Phillips Date: Wed, 29 Jun 2011 22:55:52 -0400 Subject: [PATCH 082/264] Added 'cloneonestorage' test credentials and environment-specific settings for the host URL at which StoreTweetsController should be called --- .../tweetstore/runatcloud-tweetstore/pom.xml | 33 ++++++++++--------- .../src/main/platform/cloudbees-web.xml | 20 ++++++++--- 2 files changed, 33 insertions(+), 20 deletions(-) diff --git a/demos/tweetstore/runatcloud-tweetstore/pom.xml b/demos/tweetstore/runatcloud-tweetstore/pom.xml index c99f4c45c6..6839f72f53 100644 --- a/demos/tweetstore/runatcloud-tweetstore/pom.xml +++ b/demos/tweetstore/runatcloud-tweetstore/pom.xml @@ -32,9 +32,10 @@ jclouds/tweetstore - run - localhost - 8088 + + tweetstore + localhost + 8088 jclouds-tweetstore-runatcloud @@ -75,15 +76,11 @@ bees.address - ${bees.address} + ${test.bees.address} bees.port - ${bees.port} - - - bees.environment - ${bees.environment} + ${test.bees.port} bees.basedir @@ -171,17 +168,21 @@ test.aws-s3.credential ${test.aws-s3.credential} + + test.cloudonestorage.identity + ${test.cloudonestorage.identity} + + + test.cloudonestorage.credential + ${test.cloudonestorage.credential} + bees.address - ${bees.address} + ${test.bees.address} bees.port - ${bees.port} - - - bees.environment - ${bees.environment} + ${test.bees.port} jclouds.tweetstore.blobstores @@ -233,7 +234,7 @@ bees-maven-plugin 1.0-SNAPSHOT - ${bees.environment} + run ${bees.apikey} ${bees.secret} diff --git a/demos/tweetstore/runatcloud-tweetstore/src/main/platform/cloudbees-web.xml b/demos/tweetstore/runatcloud-tweetstore/src/main/platform/cloudbees-web.xml index 607745f47c..4116a2e33e 100644 --- a/demos/tweetstore/runatcloud-tweetstore/src/main/platform/cloudbees-web.xml +++ b/demos/tweetstore/runatcloud-tweetstore/src/main/platform/cloudbees-web.xml @@ -1,8 +1,20 @@ ${bees.appid} - - application.environment - ${bees.environment} - + + + + application.host + ${test.bees.address}:${test.bees.port} + + + + + + + application.host + ${bees.apptitle}.jclouds.cloudbees.net + + \ No newline at end of file From d8443bec4dc9e62d97fb7bbbf3a0b7519c76cced Mon Sep 17 00:00:00 2001 From: Andrew Phillips Date: Wed, 29 Jun 2011 22:59:21 -0400 Subject: [PATCH 083/264] Using an RFC 2068-compliant header for 'trusted' requestors and integration-test-specific settings for the local RunAtCloudServer --- .../demo/tweetstore/config/utils/HttpRequestTask.java | 5 ++--- .../tweetstore/controller/StoreTweetsController.java | 7 ++++--- .../demo/tweetstore/integration/TweetStoreLiveTest.java | 9 +++++---- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/demos/tweetstore/runatcloud-tweetstore/src/main/java/org/jclouds/demo/tweetstore/config/utils/HttpRequestTask.java b/demos/tweetstore/runatcloud-tweetstore/src/main/java/org/jclouds/demo/tweetstore/config/utils/HttpRequestTask.java index fe28b80802..9c35a8c60f 100644 --- a/demos/tweetstore/runatcloud-tweetstore/src/main/java/org/jclouds/demo/tweetstore/config/utils/HttpRequestTask.java +++ b/demos/tweetstore/runatcloud-tweetstore/src/main/java/org/jclouds/demo/tweetstore/config/utils/HttpRequestTask.java @@ -3,6 +3,7 @@ package org.jclouds.demo.tweetstore.config.utils; import static com.google.common.base.Preconditions.checkNotNull; import static com.google.inject.name.Names.bindProperties; import static java.lang.String.format; +import static org.jclouds.demo.tweetstore.controller.StoreTweetsController.AUTHORIZED_REQUEST_ORIGINATOR_HEADER; import java.util.Properties; @@ -31,8 +32,6 @@ public class HttpRequestTask implements Runnable { } public static class Factory { - private static final String HTTP_REQUEST_ORIGINATOR_HEADER = "X-RUN@cloud-Originator"; - protected final HttpCommandExecutorService httpClient; protected final String originator; @@ -56,7 +55,7 @@ public class HttpRequestTask implements Runnable { public HttpRequestTask create(HttpRequest request) { HttpRequest requestWithSubmitter = request.toBuilder().headers( copyOfWithEntry(request.getHeaders(), - HTTP_REQUEST_ORIGINATOR_HEADER, originator)).build(); + AUTHORIZED_REQUEST_ORIGINATOR_HEADER, originator)).build(); return new HttpRequestTask(httpClient, requestWithSubmitter); } diff --git a/demos/tweetstore/runatcloud-tweetstore/src/main/java/org/jclouds/demo/tweetstore/controller/StoreTweetsController.java b/demos/tweetstore/runatcloud-tweetstore/src/main/java/org/jclouds/demo/tweetstore/controller/StoreTweetsController.java index efe708ea23..037c4a6dbb 100644 --- a/demos/tweetstore/runatcloud-tweetstore/src/main/java/org/jclouds/demo/tweetstore/controller/StoreTweetsController.java +++ b/demos/tweetstore/runatcloud-tweetstore/src/main/java/org/jclouds/demo/tweetstore/controller/StoreTweetsController.java @@ -53,7 +53,8 @@ import com.google.common.base.Function; */ @Singleton public class StoreTweetsController extends HttpServlet { - + public static final String AUTHORIZED_REQUEST_ORIGINATOR_HEADER = "X-RUNatcloud-Originator"; + private static final class StatusToBlob implements Function { private final BlobMap map; @@ -109,8 +110,8 @@ public class StoreTweetsController extends HttpServlet { @Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { - if (request.getHeader("X-RUN@cloud-Submitter") != null - && request.getHeader("X-RUN@cloud-Submitter").equals("twitter")) { + if (request.getHeader(AUTHORIZED_REQUEST_ORIGINATOR_HEADER) != null + && request.getHeader(AUTHORIZED_REQUEST_ORIGINATOR_HEADER).equals("twitter")) { try { String contextName = checkNotNull(request.getHeader("context"), "missing header context"); logger.info("retrieving tweets"); diff --git a/demos/tweetstore/runatcloud-tweetstore/src/test/java/org/jclouds/demo/tweetstore/integration/TweetStoreLiveTest.java b/demos/tweetstore/runatcloud-tweetstore/src/test/java/org/jclouds/demo/tweetstore/integration/TweetStoreLiveTest.java index 174b2e95fc..1066dc4138 100644 --- a/demos/tweetstore/runatcloud-tweetstore/src/test/java/org/jclouds/demo/tweetstore/integration/TweetStoreLiveTest.java +++ b/demos/tweetstore/runatcloud-tweetstore/src/test/java/org/jclouds/demo/tweetstore/integration/TweetStoreLiveTest.java @@ -19,6 +19,7 @@ package org.jclouds.demo.tweetstore.integration; import static com.google.common.base.Preconditions.checkNotNull; +import static org.jclouds.demo.tweetstore.controller.StoreTweetsController.AUTHORIZED_REQUEST_ORIGINATOR_HEADER; import static org.jclouds.demo.tweetstore.reference.TweetStoreConstants.PROPERTY_TWEETSTORE_BLOBSTORES; import static org.jclouds.demo.tweetstore.reference.TweetStoreConstants.PROPERTY_TWEETSTORE_CONTAINER; import static org.jclouds.demo.tweetstore.reference.TwitterConstants.PROPERTY_TWITTER_ACCESSTOKEN; @@ -173,13 +174,13 @@ public class TweetStoreLiveTest { } @BeforeTest(dependsOnMethods = "clearAndCreateContainers") - @Parameters({ "warfile", "bees.address", "bees.port", "bees.environment", "bees.basedir" }) + @Parameters({ "warfile", "bees.address", "bees.port", "bees.basedir" }) public void startDevAppServer(final String warfile, final String address, final String port, - String environments, String serverBaseDirectory) throws Exception { + String serverBaseDirectory) throws Exception { url = new URL(String.format("http://%s:%s", address, port)); server = new RunAtCloudServer(); - server.writePropertiesAndStartServer(address, port, warfile, environments, + server.writePropertiesAndStartServer(address, port, warfile, "itest", serverBaseDirectory, props); } @@ -202,7 +203,7 @@ public class TweetStoreLiveTest { for (String context : blobstores) { System.out.println("storing at context: " + context); HttpURLConnection connection = (HttpURLConnection) gurl.openConnection(); - connection.addRequestProperty("X-RUN@cloud-Submitter", "twitter"); + connection.addRequestProperty(AUTHORIZED_REQUEST_ORIGINATOR_HEADER, "twitter"); connection.addRequestProperty("context", context); InputStream i = connection.getInputStream(); String string = Strings2.toStringAndClose(i); From 75b336b83fd93648c61f6fa25f04b85a261fb51d Mon Sep 17 00:00:00 2001 From: Andrew Phillips Date: Wed, 29 Jun 2011 23:01:22 -0400 Subject: [PATCH 084/264] Constructing the request URL for the 'store' callback using context-specific settings --- .../demo/tweetstore/config/GuiceServletConfig.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/demos/tweetstore/runatcloud-tweetstore/src/main/java/org/jclouds/demo/tweetstore/config/GuiceServletConfig.java b/demos/tweetstore/runatcloud-tweetstore/src/main/java/org/jclouds/demo/tweetstore/config/GuiceServletConfig.java index 93c9972ad6..a8e76176aa 100644 --- a/demos/tweetstore/runatcloud-tweetstore/src/main/java/org/jclouds/demo/tweetstore/config/GuiceServletConfig.java +++ b/demos/tweetstore/runatcloud-tweetstore/src/main/java/org/jclouds/demo/tweetstore/config/GuiceServletConfig.java @@ -33,6 +33,7 @@ import java.util.Map; import java.util.Properties; import java.util.Set; +import javax.servlet.ServletContext; import javax.servlet.ServletContextEvent; import org.jclouds.blobstore.BlobStoreContext; @@ -109,14 +110,19 @@ public class GuiceServletConfig extends GuiceServletContextListener { // submit a job to store tweets for each configured blobstore for (String name : providerTypeToBlobStoreMap.keySet()) { queue.add(taskFactory.create(HttpRequest.builder() - .endpoint(URI.create("http://localhost:8080" + servletContextEvent.getServletContext().getContextPath() + "/store/do")) - .headers(ImmutableMultimap.of("context", name, "X-RUN@cloud-QueueName", "twitter")) + .endpoint(withUrl(servletContextEvent.getServletContext(), "/store/do")) + .headers(ImmutableMultimap.of("context", name)) .method("GET").build())); } super.contextInitialized(servletContextEvent); } + private static URI withUrl(ServletContext servletContext, String url) { + return URI.create("http://" + servletContext.getInitParameter("application.host") + + servletContext.getContextPath() + url); + } + private Properties loadJCloudsProperties( ServletContextEvent servletContextEvent) { InputStream input = servletContextEvent.getServletContext() From 6394370ddfc0e4c08eafd738f6cc2877273fec06 Mon Sep 17 00:00:00 2001 From: Adrian Cole Date: Fri, 1 Jul 2011 16:22:38 -0700 Subject: [PATCH 085/264] Issue 610: adjusted vcloud code to match greenhouse settings --- ...HouseDataElementVCloudPropertiesBuilder.java | 2 +- ...lementVCloudComputeServiceContextModule.java | 10 +++++----- ...DataElementVCloudComputeServiceLiveTest.java | 17 ----------------- ...ataElementVCloudTemplateBuilderLiveTest.java | 11 ++++++++--- 4 files changed, 14 insertions(+), 26 deletions(-) diff --git a/sandbox-providers/greenhousedata-element-vcloud/src/main/java/org/jclouds/greenhousedata/element/vcloud/GreenHouseDataElementVCloudPropertiesBuilder.java b/sandbox-providers/greenhousedata-element-vcloud/src/main/java/org/jclouds/greenhousedata/element/vcloud/GreenHouseDataElementVCloudPropertiesBuilder.java index f709e70dcd..a5ffcae3e8 100644 --- a/sandbox-providers/greenhousedata-element-vcloud/src/main/java/org/jclouds/greenhousedata/element/vcloud/GreenHouseDataElementVCloudPropertiesBuilder.java +++ b/sandbox-providers/greenhousedata-element-vcloud/src/main/java/org/jclouds/greenhousedata/element/vcloud/GreenHouseDataElementVCloudPropertiesBuilder.java @@ -36,7 +36,7 @@ public class GreenHouseDataElementVCloudPropertiesBuilder extends VCloudProperti Properties properties = super.defaultProperties(); properties.setProperty(PROPERTY_ISO3166_CODES, "US-WY"); properties.setProperty(PROPERTY_ENDPOINT, "https://mycloud.greenhousedata.com/api"); - properties.setProperty(PROPERTY_VCLOUD_DEFAULT_NETWORK, "orgNet-.*-Internal-Routed"); + properties.setProperty(PROPERTY_VCLOUD_DEFAULT_NETWORK, "orgNet-.*-External"); return properties; } diff --git a/sandbox-providers/greenhousedata-element-vcloud/src/main/java/org/jclouds/greenhousedata/element/vcloud/config/GreenHouseDataElementVCloudComputeServiceContextModule.java b/sandbox-providers/greenhousedata-element-vcloud/src/main/java/org/jclouds/greenhousedata/element/vcloud/config/GreenHouseDataElementVCloudComputeServiceContextModule.java index 495d018c5e..3d3e8ed027 100644 --- a/sandbox-providers/greenhousedata-element-vcloud/src/main/java/org/jclouds/greenhousedata/element/vcloud/config/GreenHouseDataElementVCloudComputeServiceContextModule.java +++ b/sandbox-providers/greenhousedata-element-vcloud/src/main/java/org/jclouds/greenhousedata/element/vcloud/config/GreenHouseDataElementVCloudComputeServiceContextModule.java @@ -18,9 +18,10 @@ */ package org.jclouds.greenhousedata.element.vcloud.config; -import org.jclouds.compute.domain.OsFamily; -import org.jclouds.compute.domain.TemplateBuilder; +import org.jclouds.compute.options.TemplateOptions; import org.jclouds.vcloud.compute.config.VCloudComputeServiceContextModule; +import org.jclouds.vcloud.compute.options.VCloudTemplateOptions; +import org.jclouds.vcloud.domain.network.IpAddressAllocationMode; import com.google.inject.Injector; @@ -31,9 +32,8 @@ import com.google.inject.Injector; */ public class GreenHouseDataElementVCloudComputeServiceContextModule extends VCloudComputeServiceContextModule { - //CentOS template matches Linux incorrectly @Override - protected TemplateBuilder provideTemplate(Injector injector, TemplateBuilder template) { - return template.osFamily(OsFamily.LINUX); + protected TemplateOptions provideTemplateOptions(Injector injector, TemplateOptions options) { + return options.as(VCloudTemplateOptions.class).ipAddressAllocationMode(IpAddressAllocationMode.POOL); } } diff --git a/sandbox-providers/greenhousedata-element-vcloud/src/test/java/org/jclouds/greenhousedata/element/vcloud/compute/GreenHouseDataElementVCloudComputeServiceLiveTest.java b/sandbox-providers/greenhousedata-element-vcloud/src/test/java/org/jclouds/greenhousedata/element/vcloud/compute/GreenHouseDataElementVCloudComputeServiceLiveTest.java index 41eab617cb..9f8e9576d8 100644 --- a/sandbox-providers/greenhousedata-element-vcloud/src/test/java/org/jclouds/greenhousedata/element/vcloud/compute/GreenHouseDataElementVCloudComputeServiceLiveTest.java +++ b/sandbox-providers/greenhousedata-element-vcloud/src/test/java/org/jclouds/greenhousedata/element/vcloud/compute/GreenHouseDataElementVCloudComputeServiceLiveTest.java @@ -18,14 +18,9 @@ */ package org.jclouds.greenhousedata.element.vcloud.compute; -import static org.jclouds.compute.util.ComputeServiceUtils.getCores; -import static org.testng.Assert.assertEquals; - import org.jclouds.compute.domain.Image; -import org.jclouds.compute.domain.OsFamily; import org.jclouds.compute.domain.Template; import org.jclouds.compute.domain.TemplateBuilder; -import org.jclouds.compute.predicates.OperatingSystemPredicates; import org.jclouds.vcloud.compute.VCloudComputeServiceLiveTest; import org.testng.annotations.Test; @@ -47,18 +42,6 @@ public class GreenHouseDataElementVCloudComputeServiceLiveTest extends VCloudCom group = "director"; } - @Test - public void testTemplateBuilder() { - Template defaultTemplate = client.templateBuilder().build(); - assertEquals(defaultTemplate.getImage().getOperatingSystem().is64Bit(), true); - assert OperatingSystemPredicates.supportsApt().apply(defaultTemplate.getImage().getOperatingSystem()); - assertEquals(defaultTemplate.getImage().getOperatingSystem().getFamily(), OsFamily.UBUNTU); - assertEquals(defaultTemplate.getImage().getOperatingSystem().getDescription(), "Ubuntu Linux (64-bit)"); - assert defaultTemplate.getLocation().getId() != null : defaultTemplate.getLocation(); - assertEquals(getCores(defaultTemplate.getHardware()), 1.0d); - System.out.println(defaultTemplate.getHardware()); - } - @Override protected Template buildTemplate(TemplateBuilder templateBuilder) { Template template = super.buildTemplate(templateBuilder); diff --git a/sandbox-providers/greenhousedata-element-vcloud/src/test/java/org/jclouds/greenhousedata/element/vcloud/compute/GreenHouseDataElementVCloudTemplateBuilderLiveTest.java b/sandbox-providers/greenhousedata-element-vcloud/src/test/java/org/jclouds/greenhousedata/element/vcloud/compute/GreenHouseDataElementVCloudTemplateBuilderLiveTest.java index 8de5f13d76..eb7c9a283d 100644 --- a/sandbox-providers/greenhousedata-element-vcloud/src/test/java/org/jclouds/greenhousedata/element/vcloud/compute/GreenHouseDataElementVCloudTemplateBuilderLiveTest.java +++ b/sandbox-providers/greenhousedata-element-vcloud/src/test/java/org/jclouds/greenhousedata/element/vcloud/compute/GreenHouseDataElementVCloudTemplateBuilderLiveTest.java @@ -50,7 +50,12 @@ public class GreenHouseDataElementVCloudTemplateBuilderLiveTest extends BaseTemp @Override public boolean apply(OsFamilyVersion64Bit input) { - return true; + switch (input.family) { + case UBUNTU: + return !input.version.equals("") || !input.is64Bit; + default: + return true; + } } }; @@ -61,8 +66,8 @@ public class GreenHouseDataElementVCloudTemplateBuilderLiveTest extends BaseTemp Template defaultTemplate = context.getComputeService().templateBuilder().build(); assertEquals(defaultTemplate.getImage().getOperatingSystem().getVersion(), ""); assertEquals(defaultTemplate.getImage().getOperatingSystem().is64Bit(), true); - assertEquals(defaultTemplate.getImage().getOperatingSystem().getFamily(), OsFamily.LINUX); - assertEquals(getCores(defaultTemplate.getHardware()), 2.0d); + assertEquals(defaultTemplate.getImage().getOperatingSystem().getFamily(), OsFamily.UBUNTU); + assertEquals(getCores(defaultTemplate.getHardware()), 1.0d); } @Override From b1e5bb6adea6c1f8a54f948e861a14db8f21e01b Mon Sep 17 00:00:00 2001 From: Adrian Cole Date: Fri, 1 Jul 2011 16:26:11 -0700 Subject: [PATCH 086/264] Issue 610: greenhousedata-element-vcloud now out of sandbox --- README.txt | 3 ++- allcompute/pom.xml | 5 +++++ .../greenhousedata-element-vcloud/pom.xml | 0 .../vcloud/GreenHouseDataElementVCloudContextBuilder.java | 0 .../vcloud/GreenHouseDataElementVCloudPropertiesBuilder.java | 0 .../vcloud/GreenHouseDataElementVCloudProviderMetadata.java | 0 ...eenHouseDataElementVCloudComputeServiceContextModule.java | 0 .../config/GreenHouseDataElementVCloudRestClientModule.java | 0 .../META-INF/services/org.jclouds.providers.ProviderMetadata | 0 .../DeprecatedGreenHouseDataElementVCloudClientLiveTest.java | 0 .../vcloud/GreenHouseDataElementVCloudProviderTest.java | 0 .../GreenHouseDataElementVCloudComputeServiceLiveTest.java | 0 .../GreenHouseDataElementVCloudTemplateBuilderLiveTest.java | 0 .../GreenHouseDataElementVCloudCatalogClientLiveTest.java | 0 .../GreenHouseDataElementVCloudNetworkClientLiveTest.java | 0 .../GreenHouseDataElementVCloudOrgClientLiveTest.java | 0 .../GreenHouseDataElementVCloudTaskClientLiveTest.java | 0 .../GreenHouseDataElementVCloudVAppClientLiveTest.java | 0 ...reenHouseDataElementVCloudVAppTemplateClientLiveTest.java | 0 .../GreenHouseDataElementVCloudVDCClientLiveTest.java | 0 .../GreenHouseDataElementVCloudVmClientLiveTest.java | 0 .../src/test/resources/log4j.xml | 0 providers/pom.xml | 1 + 23 files changed, 8 insertions(+), 1 deletion(-) rename {sandbox-providers => providers}/greenhousedata-element-vcloud/pom.xml (100%) rename {sandbox-providers => providers}/greenhousedata-element-vcloud/src/main/java/org/jclouds/greenhousedata/element/vcloud/GreenHouseDataElementVCloudContextBuilder.java (100%) rename {sandbox-providers => providers}/greenhousedata-element-vcloud/src/main/java/org/jclouds/greenhousedata/element/vcloud/GreenHouseDataElementVCloudPropertiesBuilder.java (100%) rename {sandbox-providers => providers}/greenhousedata-element-vcloud/src/main/java/org/jclouds/greenhousedata/element/vcloud/GreenHouseDataElementVCloudProviderMetadata.java (100%) rename {sandbox-providers => providers}/greenhousedata-element-vcloud/src/main/java/org/jclouds/greenhousedata/element/vcloud/config/GreenHouseDataElementVCloudComputeServiceContextModule.java (100%) rename {sandbox-providers => providers}/greenhousedata-element-vcloud/src/main/java/org/jclouds/greenhousedata/element/vcloud/config/GreenHouseDataElementVCloudRestClientModule.java (100%) rename {sandbox-providers => providers}/greenhousedata-element-vcloud/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata (100%) rename {sandbox-providers => providers}/greenhousedata-element-vcloud/src/test/java/org/jclouds/greenhousedata/element/vcloud/DeprecatedGreenHouseDataElementVCloudClientLiveTest.java (100%) rename {sandbox-providers => providers}/greenhousedata-element-vcloud/src/test/java/org/jclouds/greenhousedata/element/vcloud/GreenHouseDataElementVCloudProviderTest.java (100%) rename {sandbox-providers => providers}/greenhousedata-element-vcloud/src/test/java/org/jclouds/greenhousedata/element/vcloud/compute/GreenHouseDataElementVCloudComputeServiceLiveTest.java (100%) rename {sandbox-providers => providers}/greenhousedata-element-vcloud/src/test/java/org/jclouds/greenhousedata/element/vcloud/compute/GreenHouseDataElementVCloudTemplateBuilderLiveTest.java (100%) rename {sandbox-providers => providers}/greenhousedata-element-vcloud/src/test/java/org/jclouds/greenhousedata/element/vcloud/features/GreenHouseDataElementVCloudCatalogClientLiveTest.java (100%) rename {sandbox-providers => providers}/greenhousedata-element-vcloud/src/test/java/org/jclouds/greenhousedata/element/vcloud/features/GreenHouseDataElementVCloudNetworkClientLiveTest.java (100%) rename {sandbox-providers => providers}/greenhousedata-element-vcloud/src/test/java/org/jclouds/greenhousedata/element/vcloud/features/GreenHouseDataElementVCloudOrgClientLiveTest.java (100%) rename {sandbox-providers => providers}/greenhousedata-element-vcloud/src/test/java/org/jclouds/greenhousedata/element/vcloud/features/GreenHouseDataElementVCloudTaskClientLiveTest.java (100%) rename {sandbox-providers => providers}/greenhousedata-element-vcloud/src/test/java/org/jclouds/greenhousedata/element/vcloud/features/GreenHouseDataElementVCloudVAppClientLiveTest.java (100%) rename {sandbox-providers => providers}/greenhousedata-element-vcloud/src/test/java/org/jclouds/greenhousedata/element/vcloud/features/GreenHouseDataElementVCloudVAppTemplateClientLiveTest.java (100%) rename {sandbox-providers => providers}/greenhousedata-element-vcloud/src/test/java/org/jclouds/greenhousedata/element/vcloud/features/GreenHouseDataElementVCloudVDCClientLiveTest.java (100%) rename {sandbox-providers => providers}/greenhousedata-element-vcloud/src/test/java/org/jclouds/greenhousedata/element/vcloud/features/GreenHouseDataElementVCloudVmClientLiveTest.java (100%) rename {sandbox-providers => providers}/greenhousedata-element-vcloud/src/test/resources/log4j.xml (100%) diff --git a/README.txt b/README.txt index 7f0b67a9eb..d1a474d120 100644 --- a/README.txt +++ b/README.txt @@ -20,7 +20,8 @@ our compute api supports: aws-ec2, gogrid, cloudservers-us, stub (in-memory), de bluelock-vcloud-zone01, stratogen-vcloud-mycloud, rimuhosting, slicehost, eucalyptus-partnercloud-ec2, elastichosts-lon-p (Peer 1), elastichosts-sat-p (Peer 1), elastichosts-lon-b (BlueSquare), - openhosting-east1, serverlove-z1-man, skalicloud-sdg-my + openhosting-east1, serverlove-z1-man, skalicloud-sdg-my, + greenhousedata-element-vcloud * note * the pom dependency org.jclouds/jclouds-allcompute gives you access to to all of these providers diff --git a/allcompute/pom.xml b/allcompute/pom.xml index e4d0141f12..1b69b056e9 100644 --- a/allcompute/pom.xml +++ b/allcompute/pom.xml @@ -29,6 +29,11 @@ jclouds-allcompute allcompute + + org.jclouds.provider + greenhousedata-element-vcloud + ${project.version} + org.jclouds.provider savvis-symphonyvpdc diff --git a/sandbox-providers/greenhousedata-element-vcloud/pom.xml b/providers/greenhousedata-element-vcloud/pom.xml similarity index 100% rename from sandbox-providers/greenhousedata-element-vcloud/pom.xml rename to providers/greenhousedata-element-vcloud/pom.xml diff --git a/sandbox-providers/greenhousedata-element-vcloud/src/main/java/org/jclouds/greenhousedata/element/vcloud/GreenHouseDataElementVCloudContextBuilder.java b/providers/greenhousedata-element-vcloud/src/main/java/org/jclouds/greenhousedata/element/vcloud/GreenHouseDataElementVCloudContextBuilder.java similarity index 100% rename from sandbox-providers/greenhousedata-element-vcloud/src/main/java/org/jclouds/greenhousedata/element/vcloud/GreenHouseDataElementVCloudContextBuilder.java rename to providers/greenhousedata-element-vcloud/src/main/java/org/jclouds/greenhousedata/element/vcloud/GreenHouseDataElementVCloudContextBuilder.java diff --git a/sandbox-providers/greenhousedata-element-vcloud/src/main/java/org/jclouds/greenhousedata/element/vcloud/GreenHouseDataElementVCloudPropertiesBuilder.java b/providers/greenhousedata-element-vcloud/src/main/java/org/jclouds/greenhousedata/element/vcloud/GreenHouseDataElementVCloudPropertiesBuilder.java similarity index 100% rename from sandbox-providers/greenhousedata-element-vcloud/src/main/java/org/jclouds/greenhousedata/element/vcloud/GreenHouseDataElementVCloudPropertiesBuilder.java rename to providers/greenhousedata-element-vcloud/src/main/java/org/jclouds/greenhousedata/element/vcloud/GreenHouseDataElementVCloudPropertiesBuilder.java diff --git a/sandbox-providers/greenhousedata-element-vcloud/src/main/java/org/jclouds/greenhousedata/element/vcloud/GreenHouseDataElementVCloudProviderMetadata.java b/providers/greenhousedata-element-vcloud/src/main/java/org/jclouds/greenhousedata/element/vcloud/GreenHouseDataElementVCloudProviderMetadata.java similarity index 100% rename from sandbox-providers/greenhousedata-element-vcloud/src/main/java/org/jclouds/greenhousedata/element/vcloud/GreenHouseDataElementVCloudProviderMetadata.java rename to providers/greenhousedata-element-vcloud/src/main/java/org/jclouds/greenhousedata/element/vcloud/GreenHouseDataElementVCloudProviderMetadata.java diff --git a/sandbox-providers/greenhousedata-element-vcloud/src/main/java/org/jclouds/greenhousedata/element/vcloud/config/GreenHouseDataElementVCloudComputeServiceContextModule.java b/providers/greenhousedata-element-vcloud/src/main/java/org/jclouds/greenhousedata/element/vcloud/config/GreenHouseDataElementVCloudComputeServiceContextModule.java similarity index 100% rename from sandbox-providers/greenhousedata-element-vcloud/src/main/java/org/jclouds/greenhousedata/element/vcloud/config/GreenHouseDataElementVCloudComputeServiceContextModule.java rename to providers/greenhousedata-element-vcloud/src/main/java/org/jclouds/greenhousedata/element/vcloud/config/GreenHouseDataElementVCloudComputeServiceContextModule.java diff --git a/sandbox-providers/greenhousedata-element-vcloud/src/main/java/org/jclouds/greenhousedata/element/vcloud/config/GreenHouseDataElementVCloudRestClientModule.java b/providers/greenhousedata-element-vcloud/src/main/java/org/jclouds/greenhousedata/element/vcloud/config/GreenHouseDataElementVCloudRestClientModule.java similarity index 100% rename from sandbox-providers/greenhousedata-element-vcloud/src/main/java/org/jclouds/greenhousedata/element/vcloud/config/GreenHouseDataElementVCloudRestClientModule.java rename to providers/greenhousedata-element-vcloud/src/main/java/org/jclouds/greenhousedata/element/vcloud/config/GreenHouseDataElementVCloudRestClientModule.java diff --git a/sandbox-providers/greenhousedata-element-vcloud/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata b/providers/greenhousedata-element-vcloud/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata similarity index 100% rename from sandbox-providers/greenhousedata-element-vcloud/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata rename to providers/greenhousedata-element-vcloud/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata diff --git a/sandbox-providers/greenhousedata-element-vcloud/src/test/java/org/jclouds/greenhousedata/element/vcloud/DeprecatedGreenHouseDataElementVCloudClientLiveTest.java b/providers/greenhousedata-element-vcloud/src/test/java/org/jclouds/greenhousedata/element/vcloud/DeprecatedGreenHouseDataElementVCloudClientLiveTest.java similarity index 100% rename from sandbox-providers/greenhousedata-element-vcloud/src/test/java/org/jclouds/greenhousedata/element/vcloud/DeprecatedGreenHouseDataElementVCloudClientLiveTest.java rename to providers/greenhousedata-element-vcloud/src/test/java/org/jclouds/greenhousedata/element/vcloud/DeprecatedGreenHouseDataElementVCloudClientLiveTest.java diff --git a/sandbox-providers/greenhousedata-element-vcloud/src/test/java/org/jclouds/greenhousedata/element/vcloud/GreenHouseDataElementVCloudProviderTest.java b/providers/greenhousedata-element-vcloud/src/test/java/org/jclouds/greenhousedata/element/vcloud/GreenHouseDataElementVCloudProviderTest.java similarity index 100% rename from sandbox-providers/greenhousedata-element-vcloud/src/test/java/org/jclouds/greenhousedata/element/vcloud/GreenHouseDataElementVCloudProviderTest.java rename to providers/greenhousedata-element-vcloud/src/test/java/org/jclouds/greenhousedata/element/vcloud/GreenHouseDataElementVCloudProviderTest.java diff --git a/sandbox-providers/greenhousedata-element-vcloud/src/test/java/org/jclouds/greenhousedata/element/vcloud/compute/GreenHouseDataElementVCloudComputeServiceLiveTest.java b/providers/greenhousedata-element-vcloud/src/test/java/org/jclouds/greenhousedata/element/vcloud/compute/GreenHouseDataElementVCloudComputeServiceLiveTest.java similarity index 100% rename from sandbox-providers/greenhousedata-element-vcloud/src/test/java/org/jclouds/greenhousedata/element/vcloud/compute/GreenHouseDataElementVCloudComputeServiceLiveTest.java rename to providers/greenhousedata-element-vcloud/src/test/java/org/jclouds/greenhousedata/element/vcloud/compute/GreenHouseDataElementVCloudComputeServiceLiveTest.java diff --git a/sandbox-providers/greenhousedata-element-vcloud/src/test/java/org/jclouds/greenhousedata/element/vcloud/compute/GreenHouseDataElementVCloudTemplateBuilderLiveTest.java b/providers/greenhousedata-element-vcloud/src/test/java/org/jclouds/greenhousedata/element/vcloud/compute/GreenHouseDataElementVCloudTemplateBuilderLiveTest.java similarity index 100% rename from sandbox-providers/greenhousedata-element-vcloud/src/test/java/org/jclouds/greenhousedata/element/vcloud/compute/GreenHouseDataElementVCloudTemplateBuilderLiveTest.java rename to providers/greenhousedata-element-vcloud/src/test/java/org/jclouds/greenhousedata/element/vcloud/compute/GreenHouseDataElementVCloudTemplateBuilderLiveTest.java diff --git a/sandbox-providers/greenhousedata-element-vcloud/src/test/java/org/jclouds/greenhousedata/element/vcloud/features/GreenHouseDataElementVCloudCatalogClientLiveTest.java b/providers/greenhousedata-element-vcloud/src/test/java/org/jclouds/greenhousedata/element/vcloud/features/GreenHouseDataElementVCloudCatalogClientLiveTest.java similarity index 100% rename from sandbox-providers/greenhousedata-element-vcloud/src/test/java/org/jclouds/greenhousedata/element/vcloud/features/GreenHouseDataElementVCloudCatalogClientLiveTest.java rename to providers/greenhousedata-element-vcloud/src/test/java/org/jclouds/greenhousedata/element/vcloud/features/GreenHouseDataElementVCloudCatalogClientLiveTest.java diff --git a/sandbox-providers/greenhousedata-element-vcloud/src/test/java/org/jclouds/greenhousedata/element/vcloud/features/GreenHouseDataElementVCloudNetworkClientLiveTest.java b/providers/greenhousedata-element-vcloud/src/test/java/org/jclouds/greenhousedata/element/vcloud/features/GreenHouseDataElementVCloudNetworkClientLiveTest.java similarity index 100% rename from sandbox-providers/greenhousedata-element-vcloud/src/test/java/org/jclouds/greenhousedata/element/vcloud/features/GreenHouseDataElementVCloudNetworkClientLiveTest.java rename to providers/greenhousedata-element-vcloud/src/test/java/org/jclouds/greenhousedata/element/vcloud/features/GreenHouseDataElementVCloudNetworkClientLiveTest.java diff --git a/sandbox-providers/greenhousedata-element-vcloud/src/test/java/org/jclouds/greenhousedata/element/vcloud/features/GreenHouseDataElementVCloudOrgClientLiveTest.java b/providers/greenhousedata-element-vcloud/src/test/java/org/jclouds/greenhousedata/element/vcloud/features/GreenHouseDataElementVCloudOrgClientLiveTest.java similarity index 100% rename from sandbox-providers/greenhousedata-element-vcloud/src/test/java/org/jclouds/greenhousedata/element/vcloud/features/GreenHouseDataElementVCloudOrgClientLiveTest.java rename to providers/greenhousedata-element-vcloud/src/test/java/org/jclouds/greenhousedata/element/vcloud/features/GreenHouseDataElementVCloudOrgClientLiveTest.java diff --git a/sandbox-providers/greenhousedata-element-vcloud/src/test/java/org/jclouds/greenhousedata/element/vcloud/features/GreenHouseDataElementVCloudTaskClientLiveTest.java b/providers/greenhousedata-element-vcloud/src/test/java/org/jclouds/greenhousedata/element/vcloud/features/GreenHouseDataElementVCloudTaskClientLiveTest.java similarity index 100% rename from sandbox-providers/greenhousedata-element-vcloud/src/test/java/org/jclouds/greenhousedata/element/vcloud/features/GreenHouseDataElementVCloudTaskClientLiveTest.java rename to providers/greenhousedata-element-vcloud/src/test/java/org/jclouds/greenhousedata/element/vcloud/features/GreenHouseDataElementVCloudTaskClientLiveTest.java diff --git a/sandbox-providers/greenhousedata-element-vcloud/src/test/java/org/jclouds/greenhousedata/element/vcloud/features/GreenHouseDataElementVCloudVAppClientLiveTest.java b/providers/greenhousedata-element-vcloud/src/test/java/org/jclouds/greenhousedata/element/vcloud/features/GreenHouseDataElementVCloudVAppClientLiveTest.java similarity index 100% rename from sandbox-providers/greenhousedata-element-vcloud/src/test/java/org/jclouds/greenhousedata/element/vcloud/features/GreenHouseDataElementVCloudVAppClientLiveTest.java rename to providers/greenhousedata-element-vcloud/src/test/java/org/jclouds/greenhousedata/element/vcloud/features/GreenHouseDataElementVCloudVAppClientLiveTest.java diff --git a/sandbox-providers/greenhousedata-element-vcloud/src/test/java/org/jclouds/greenhousedata/element/vcloud/features/GreenHouseDataElementVCloudVAppTemplateClientLiveTest.java b/providers/greenhousedata-element-vcloud/src/test/java/org/jclouds/greenhousedata/element/vcloud/features/GreenHouseDataElementVCloudVAppTemplateClientLiveTest.java similarity index 100% rename from sandbox-providers/greenhousedata-element-vcloud/src/test/java/org/jclouds/greenhousedata/element/vcloud/features/GreenHouseDataElementVCloudVAppTemplateClientLiveTest.java rename to providers/greenhousedata-element-vcloud/src/test/java/org/jclouds/greenhousedata/element/vcloud/features/GreenHouseDataElementVCloudVAppTemplateClientLiveTest.java diff --git a/sandbox-providers/greenhousedata-element-vcloud/src/test/java/org/jclouds/greenhousedata/element/vcloud/features/GreenHouseDataElementVCloudVDCClientLiveTest.java b/providers/greenhousedata-element-vcloud/src/test/java/org/jclouds/greenhousedata/element/vcloud/features/GreenHouseDataElementVCloudVDCClientLiveTest.java similarity index 100% rename from sandbox-providers/greenhousedata-element-vcloud/src/test/java/org/jclouds/greenhousedata/element/vcloud/features/GreenHouseDataElementVCloudVDCClientLiveTest.java rename to providers/greenhousedata-element-vcloud/src/test/java/org/jclouds/greenhousedata/element/vcloud/features/GreenHouseDataElementVCloudVDCClientLiveTest.java diff --git a/sandbox-providers/greenhousedata-element-vcloud/src/test/java/org/jclouds/greenhousedata/element/vcloud/features/GreenHouseDataElementVCloudVmClientLiveTest.java b/providers/greenhousedata-element-vcloud/src/test/java/org/jclouds/greenhousedata/element/vcloud/features/GreenHouseDataElementVCloudVmClientLiveTest.java similarity index 100% rename from sandbox-providers/greenhousedata-element-vcloud/src/test/java/org/jclouds/greenhousedata/element/vcloud/features/GreenHouseDataElementVCloudVmClientLiveTest.java rename to providers/greenhousedata-element-vcloud/src/test/java/org/jclouds/greenhousedata/element/vcloud/features/GreenHouseDataElementVCloudVmClientLiveTest.java diff --git a/sandbox-providers/greenhousedata-element-vcloud/src/test/resources/log4j.xml b/providers/greenhousedata-element-vcloud/src/test/resources/log4j.xml similarity index 100% rename from sandbox-providers/greenhousedata-element-vcloud/src/test/resources/log4j.xml rename to providers/greenhousedata-element-vcloud/src/test/resources/log4j.xml diff --git a/providers/pom.xml b/providers/pom.xml index aee01547f0..302ebc64c0 100644 --- a/providers/pom.xml +++ b/providers/pom.xml @@ -63,5 +63,6 @@ serverlove-z1-man skalicloud-sdg-my savvis-symphonyvpdc + greenhousedata-element-vcloud From 521d3c3289b336d270f78c3585cace2f4e347778 Mon Sep 17 00:00:00 2001 From: Adrian Cole Date: Fri, 1 Jul 2011 16:29:25 -0700 Subject: [PATCH 087/264] Issue 611:copy paste error in RestContextFactory.createContextSpec --- core/src/main/java/org/jclouds/rest/RestContextFactory.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/main/java/org/jclouds/rest/RestContextFactory.java b/core/src/main/java/org/jclouds/rest/RestContextFactory.java index 5defcda0d7..a491295b4a 100644 --- a/core/src/main/java/org/jclouds/rest/RestContextFactory.java +++ b/core/src/main/java/org/jclouds/rest/RestContextFactory.java @@ -304,7 +304,7 @@ public class RestContextFactory { contextBuilderClass = Providers.resolveContextBuilderClass(providerName, props); propertiesBuilderClass = Providers.resolvePropertiesBuilderClass(providerName, props); sync = (Class) (syncClassName != null ? Class.forName(syncClassName) : null); - async = (Class) (syncClassName != null ? Class.forName(asyncClassName) : null); + async = (Class) (asyncClassName != null ? Class.forName(asyncClassName) : null); } catch (IllegalArgumentException e) { throw new IllegalArgumentException( String.format( From 5f00612929757ea16bdef3c776ed67058be98f68 Mon Sep 17 00:00:00 2001 From: Adrian Cole Date: Fri, 1 Jul 2011 17:37:33 -0700 Subject: [PATCH 088/264] Issue 615:enhance curl arg defaults --- .../compute/util/ComputeServiceUtilsTest.java | 4 ++-- .../domain/PipeHttpResponseTo.java | 2 +- .../domain/SaveHttpResponseTo.java | 20 +++++++++++-------- .../domain/PipeHttpResponseToTest.java | 8 ++++---- 4 files changed, 19 insertions(+), 15 deletions(-) diff --git a/compute/src/test/java/org/jclouds/compute/util/ComputeServiceUtilsTest.java b/compute/src/test/java/org/jclouds/compute/util/ComputeServiceUtilsTest.java index 8734148dba..21ac164969 100644 --- a/compute/src/test/java/org/jclouds/compute/util/ComputeServiceUtilsTest.java +++ b/compute/src/test/java/org/jclouds/compute/util/ComputeServiceUtilsTest.java @@ -51,7 +51,7 @@ public class ComputeServiceUtilsTest { assertEquals( ComputeServiceUtils.execHttpResponse(request).render(OsFamily.UNIX), - "curl -X GET -s --retry 20 -H \"Host: adriancolehappy.s3.amazonaws.com\" -H \"Date: Sun, 12 Sep 2010 08:25:19 GMT\" -H \"Authorization: AWS 0ASHDJAS82:JASHFDA=\" https://adriancolehappy.s3.amazonaws.com/java/install |(bash)\n"); + "curl -q -s -S -L --connect-timeout 10 --max-time 600 --retry 20 -X GET -H \"Host: adriancolehappy.s3.amazonaws.com\" -H \"Date: Sun, 12 Sep 2010 08:25:19 GMT\" -H \"Authorization: AWS 0ASHDJAS82:JASHFDA=\" https://adriancolehappy.s3.amazonaws.com/java/install |(bash)\n"); } @@ -63,7 +63,7 @@ public class ComputeServiceUtilsTest { assertEquals( ComputeServiceUtils.extractTargzIntoDirectory(request, "/stage/").render(OsFamily.UNIX), - "curl -X GET -s --retry 20 -H \"Host: adriancolehappy.s3.amazonaws.com\" -H \"Date: Sun, 12 Sep 2010 08:25:19 GMT\" -H \"Authorization: AWS 0ASHDJAS82:JASHFDA=\" https://adriancolehappy.s3.amazonaws.com/java/install |(mkdir -p /stage/ &&cd /stage/ &&tar -xpzf -)\n"); + "curl -q -s -S -L --connect-timeout 10 --max-time 600 --retry 20 -X GET -H \"Host: adriancolehappy.s3.amazonaws.com\" -H \"Date: Sun, 12 Sep 2010 08:25:19 GMT\" -H \"Authorization: AWS 0ASHDJAS82:JASHFDA=\" https://adriancolehappy.s3.amazonaws.com/java/install |(mkdir -p /stage/ &&cd /stage/ &&tar -xpzf -)\n"); } } diff --git a/scriptbuilder/src/main/java/org/jclouds/scriptbuilder/domain/PipeHttpResponseTo.java b/scriptbuilder/src/main/java/org/jclouds/scriptbuilder/domain/PipeHttpResponseTo.java index 4c9caac3c1..6913f351fd 100644 --- a/scriptbuilder/src/main/java/org/jclouds/scriptbuilder/domain/PipeHttpResponseTo.java +++ b/scriptbuilder/src/main/java/org/jclouds/scriptbuilder/domain/PipeHttpResponseTo.java @@ -46,7 +46,7 @@ public class PipeHttpResponseTo extends InterpretableStatement { * request headers to send */ public PipeHttpResponseTo(Statement toExec, String method, URI endpoint, Multimap headers) { - super(String.format("curl -X %s -s --retry 20 %s %s |(%s)\n", method, Joiner.on(' ').join( + super(String.format("%s -X %s %s %s |(%s)\n", SaveHttpResponseTo.CURL, method, Joiner.on(' ').join( Iterables.transform(headers.entries(), new Function, String>() { @Override diff --git a/scriptbuilder/src/main/java/org/jclouds/scriptbuilder/domain/SaveHttpResponseTo.java b/scriptbuilder/src/main/java/org/jclouds/scriptbuilder/domain/SaveHttpResponseTo.java index ac92ba7a8f..1bf716056d 100644 --- a/scriptbuilder/src/main/java/org/jclouds/scriptbuilder/domain/SaveHttpResponseTo.java +++ b/scriptbuilder/src/main/java/org/jclouds/scriptbuilder/domain/SaveHttpResponseTo.java @@ -19,7 +19,7 @@ package org.jclouds.scriptbuilder.domain; import java.net.URI; -import java.util.Map.Entry; +import java.util.Map; import com.google.common.base.Function; import com.google.common.base.Joiner; @@ -32,6 +32,8 @@ import com.google.common.collect.Multimap; * @author Adrian Cole */ public class SaveHttpResponseTo extends InterpretableStatement { + static final String CURL = "curl -q -s -S -L --connect-timeout 10 --max-time 600 --retry 20"; + /** * * @param dir @@ -44,15 +46,17 @@ public class SaveHttpResponseTo extends InterpretableStatement { * request headers to send */ public SaveHttpResponseTo(String dir, String file, String method, URI endpoint, Multimap headers) { - super(String.format("({md} %s &&{cd} %s &&curl -X %s -s --retry 20 %s %s >%s\n", dir, dir, method, Joiner.on(' ') - .join(Iterables.transform(headers.entries(), new Function, String>() { + super(String.format("({md} %s && {cd} %s && [ ! -f %s ] && %s -C - -X %s %s %s >%s)\n", dir, dir, file, CURL, + method, Joiner.on(' ').join( + Iterables.transform(headers.entries(), new Function, String>() { - @Override - public String apply(Entry from) { - return String.format("-H \"%s: %s\"", from.getKey(), from.getValue()); - } + @Override + public String apply(Map.Entry from) { + return String.format("-H \"%s: %s\"", from.getKey(), from.getValue()); + } + + })), endpoint.toASCIIString(), file)); - })), endpoint.toASCIIString(), file)); } } \ No newline at end of file diff --git a/scriptbuilder/src/test/java/org/jclouds/scriptbuilder/domain/PipeHttpResponseToTest.java b/scriptbuilder/src/test/java/org/jclouds/scriptbuilder/domain/PipeHttpResponseToTest.java index 363ca99e0e..67e89cd0ed 100644 --- a/scriptbuilder/src/test/java/org/jclouds/scriptbuilder/domain/PipeHttpResponseToTest.java +++ b/scriptbuilder/src/test/java/org/jclouds/scriptbuilder/domain/PipeHttpResponseToTest.java @@ -44,7 +44,7 @@ public class PipeHttpResponseToTest { public void testPipeHttpResponseToBashUNIX() { assertEquals( bash.render(OsFamily.UNIX), - "curl -X GET -s --retry 20 -H \"Host: adriancolehappy.s3.amazonaws.com\" -H \"Date: Sun, 12 Sep 2010 08:25:19 GMT\" -H \"Authorization: AWS 0ASHDJAS82:JASHFDA=\" https://adriancolehappy.s3.amazonaws.com/java/install |(bash)\n"); + "curl -q -s -S -L --connect-timeout 10 --max-time 600 --retry 20 -X GET -H \"Host: adriancolehappy.s3.amazonaws.com\" -H \"Date: Sun, 12 Sep 2010 08:25:19 GMT\" -H \"Authorization: AWS 0ASHDJAS82:JASHFDA=\" https://adriancolehappy.s3.amazonaws.com/java/install |(bash)\n"); assertEquals(bash2.render(OsFamily.UNIX), bash.render(OsFamily.UNIX)); } @@ -59,15 +59,15 @@ public class PipeHttpResponseToTest { "adriancolehappy.s3.amazonaws.com", "Date", "Sun, 12 Sep 2010 08:25:19 GMT", "Authorization", "AWS 0ASHDJAS82:JASHFDA=")); - PipeHttpResponseTo untar2 = new PipeHttpResponseToTarxpzfIntoDirectory( "GET", URI + PipeHttpResponseTo untar2 = new PipeHttpResponseToTarxpzfIntoDirectory("GET", URI .create("https://adriancolehappy.s3.amazonaws.com/java/install"), ImmutableMultimap.of("Host", "adriancolehappy.s3.amazonaws.com", "Date", "Sun, 12 Sep 2010 08:25:19 GMT", "Authorization", - "AWS 0ASHDJAS82:JASHFDA="),"{root}stage{fs}"); + "AWS 0ASHDJAS82:JASHFDA="), "{root}stage{fs}"); public void testPipeHttpResponseToUntarUNIX() { assertEquals( untar.render(OsFamily.UNIX), - "curl -X GET -s --retry 20 -H \"Host: adriancolehappy.s3.amazonaws.com\" -H \"Date: Sun, 12 Sep 2010 08:25:19 GMT\" -H \"Authorization: AWS 0ASHDJAS82:JASHFDA=\" https://adriancolehappy.s3.amazonaws.com/java/install |(mkdir -p /stage/ &&cd /stage/ &&tar -xpzf -)\n"); + "curl -q -s -S -L --connect-timeout 10 --max-time 600 --retry 20 -X GET -H \"Host: adriancolehappy.s3.amazonaws.com\" -H \"Date: Sun, 12 Sep 2010 08:25:19 GMT\" -H \"Authorization: AWS 0ASHDJAS82:JASHFDA=\" https://adriancolehappy.s3.amazonaws.com/java/install |(mkdir -p /stage/ &&cd /stage/ &&tar -xpzf -)\n"); assertEquals(untar.render(OsFamily.UNIX), untar2.render(OsFamily.UNIX)); } From 0a28bbdb8a1692d98558719c27bad3cfe92292fd Mon Sep 17 00:00:00 2001 From: Adrian Cole Date: Fri, 1 Jul 2011 17:38:35 -0700 Subject: [PATCH 089/264] cloudservers now supports debian --- .../compute/CloudServersUKTemplateBuilderLiveTest.java | 2 +- .../compute/CloudServersUSTemplateBuilderLiveTest.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/providers/cloudservers-uk/src/test/java/org/jclouds/rackspace/cloudservers/compute/CloudServersUKTemplateBuilderLiveTest.java b/providers/cloudservers-uk/src/test/java/org/jclouds/rackspace/cloudservers/compute/CloudServersUKTemplateBuilderLiveTest.java index 9dcb7d1b4a..5e7e3f2b2d 100644 --- a/providers/cloudservers-uk/src/test/java/org/jclouds/rackspace/cloudservers/compute/CloudServersUKTemplateBuilderLiveTest.java +++ b/providers/cloudservers-uk/src/test/java/org/jclouds/rackspace/cloudservers/compute/CloudServersUKTemplateBuilderLiveTest.java @@ -54,7 +54,7 @@ public class CloudServersUKTemplateBuilderLiveTest extends BaseTemplateBuilderLi case UBUNTU: return !(input.version.equals("11.04") || input.version.equals("8.04")) && input.is64Bit; case DEBIAN: - return !(input.version.equals("6.0")) && input.is64Bit; + return input.is64Bit; case CENTOS: return (input.version.equals("") || input.version.matches("5.[45]")) && input.is64Bit; case WINDOWS: diff --git a/providers/cloudservers-us/src/test/java/org/jclouds/rackspace/cloudservers/compute/CloudServersUSTemplateBuilderLiveTest.java b/providers/cloudservers-us/src/test/java/org/jclouds/rackspace/cloudservers/compute/CloudServersUSTemplateBuilderLiveTest.java index 64ee3620ae..5cec87ecc0 100644 --- a/providers/cloudservers-us/src/test/java/org/jclouds/rackspace/cloudservers/compute/CloudServersUSTemplateBuilderLiveTest.java +++ b/providers/cloudservers-us/src/test/java/org/jclouds/rackspace/cloudservers/compute/CloudServersUSTemplateBuilderLiveTest.java @@ -54,7 +54,7 @@ public class CloudServersUSTemplateBuilderLiveTest extends BaseTemplateBuilderLi case UBUNTU: return !(input.version.equals("11.04") || input.version.equals("8.04")) && input.is64Bit; case DEBIAN: - return !(input.version.equals("6.0")) && input.is64Bit; + return input.is64Bit; case CENTOS: return !(input.version.matches("5.[023]")) && input.is64Bit; case WINDOWS: From b56f08b9a59392e054040b39fecaff8a66156a29 Mon Sep 17 00:00:00 2001 From: Adrian Cole Date: Fri, 1 Jul 2011 17:40:20 -0700 Subject: [PATCH 090/264] Issue 614:Add Visitor pattern support for scriptbuilder Statements --- .../RunScriptOnNodeAsInitScriptUsingSsh.java | 68 ++++-- ...itScriptUsingSshAndBlockUntilComplete.java | 11 +- .../compute/internal/BaseComputeService.java | 4 +- .../compute/BaseComputeServiceLiveTest.java | 2 +- .../jclouds/scriptbuilder/InitBuilder.java | 41 ++-- .../jclouds/scriptbuilder/ScriptBuilder.java | 11 +- .../domain/AcceptsStatementVisitor.java | 28 +++ .../domain/AdminAccessVisitor.java | 40 ++++ .../scriptbuilder/domain/CreateRunScript.java | 5 +- .../scriptbuilder/domain/StatementList.java | 9 +- .../domain/StatementVisitor.java | 27 +++ .../scriptbuilder/domain/Statements.java | 2 +- .../scriptbuilder/domain/SwitchArg.java | 9 +- .../functions/CredentialsFromAdminAccess.java | 29 ++- .../functions/InitAdminAccess.java | 23 +- .../statements/login/AdminAccess.java | 223 ++++++++++++------ .../CredentialsFromAdminAccessTest.java | 27 +++ .../functions/InitAdminAccessTest.java | 50 +++- .../statements/login/AdminAccessTest.java | 8 +- 19 files changed, 450 insertions(+), 167 deletions(-) create mode 100644 scriptbuilder/src/main/java/org/jclouds/scriptbuilder/domain/AcceptsStatementVisitor.java create mode 100644 scriptbuilder/src/main/java/org/jclouds/scriptbuilder/domain/AdminAccessVisitor.java create mode 100644 scriptbuilder/src/main/java/org/jclouds/scriptbuilder/domain/StatementVisitor.java diff --git a/compute/src/main/java/org/jclouds/compute/callables/RunScriptOnNodeAsInitScriptUsingSsh.java b/compute/src/main/java/org/jclouds/compute/callables/RunScriptOnNodeAsInitScriptUsingSsh.java index e4cefc4b50..34459c8eb7 100644 --- a/compute/src/main/java/org/jclouds/compute/callables/RunScriptOnNodeAsInitScriptUsingSsh.java +++ b/compute/src/main/java/org/jclouds/compute/callables/RunScriptOnNodeAsInitScriptUsingSsh.java @@ -28,14 +28,17 @@ import javax.inject.Named; import org.jclouds.compute.domain.ExecResponse; import org.jclouds.compute.domain.NodeMetadata; +import org.jclouds.compute.domain.NodeMetadataBuilder; import org.jclouds.compute.options.RunScriptOptions; import org.jclouds.compute.reference.ComputeServiceConstants; import org.jclouds.logging.Logger; import org.jclouds.scriptbuilder.InitBuilder; +import org.jclouds.scriptbuilder.domain.AdminAccessVisitor; import org.jclouds.scriptbuilder.domain.AppendFile; import org.jclouds.scriptbuilder.domain.OsFamily; import org.jclouds.scriptbuilder.domain.Statement; import org.jclouds.scriptbuilder.domain.Statements; +import org.jclouds.scriptbuilder.statements.login.AdminAccess; import org.jclouds.ssh.SshClient; import com.google.common.annotations.VisibleForTesting; @@ -52,15 +55,16 @@ import com.google.inject.assistedinject.AssistedInject; */ public class RunScriptOnNodeAsInitScriptUsingSsh implements RunScriptOnNode { public static final String PROPERTY_PUSH_INIT_SCRIPT_VIA_SFTP = "jclouds.compute.push-init-script-via-sftp"; + public static final String PROPERTY_INIT_SCRIPT_PATTERN = "jclouds.compute.init-script-pattern"; @Resource @Named(ComputeServiceConstants.COMPUTE_LOGGER) protected Logger logger = Logger.NULL; protected final Function sshFactory; - protected final NodeMetadata node; - protected final Statement init; - protected final String name; + protected NodeMetadata node; + protected final InitBuilder init; protected final boolean runAsRoot; + protected final String initFile; protected SshClient ssh; @@ -72,6 +76,15 @@ public class RunScriptOnNodeAsInitScriptUsingSsh implements RunScriptOnNode { @Named(PROPERTY_PUSH_INIT_SCRIPT_VIA_SFTP) private boolean pushInitViaSftp = true; + /** + * determines the naming convention of init scripts. + * + * ex. {@code /tmp/init-%s} + */ + @Inject(optional = true) + @Named(PROPERTY_INIT_SCRIPT_PATTERN) + private String initScriptPattern = "/tmp/init-%s"; + @AssistedInject public RunScriptOnNodeAsInitScriptUsingSsh(Function sshFactory, @Assisted NodeMetadata node, @Assisted Statement script, @Assisted RunScriptOptions options) { @@ -84,9 +97,9 @@ public class RunScriptOnNodeAsInitScriptUsingSsh implements RunScriptOnNode { else name = "jclouds-script-" + System.currentTimeMillis(); } - this.name = checkNotNull(name, "name"); this.init = checkNotNull(script, "script") instanceof InitBuilder ? InitBuilder.class.cast(script) : createInitScript(name, script); + this.initFile = String.format(initScriptPattern, name); this.runAsRoot = options.shouldRunAsRoot(); } @@ -113,22 +126,48 @@ public class RunScriptOnNodeAsInitScriptUsingSsh implements RunScriptOnNode { return this; } + public void refreshSshIfNewAdminCredentialsConfigured(AdminAccess input) { + if (input.getAdminCredentials() != null && input.shouldGrantSudoToAdminUser()) { + ssh.disconnect(); + logger.debug(">> reconnecting as %s@%s", input.getAdminCredentials().identity, ssh.getHostAddress()); + ssh = sshFactory.apply(node = NodeMetadataBuilder.fromNodeMetadata(node).adminPassword(null).credentials( + input.getAdminCredentials()).build()); + ssh.connect(); + setupLinkToInitFile(); + } + } + /** * ssh client is initialized through this call. */ protected ExecResponse doCall() { if (pushInitViaSftp) { - ssh.put(name, init.render(OsFamily.UNIX)); + ssh.put(initFile, init.render(OsFamily.UNIX)); } else { - ssh.exec("rm " + name); - ssh.exec(Statements.appendFile(name, Splitter.on('\n').split(init.render(OsFamily.UNIX)), - AppendFile.MARKER + "_" + name).render(OsFamily.UNIX)); + ssh.exec("rm " + initFile); + ssh.exec(Statements.appendFile(initFile, Splitter.on('\n').split(init.render(OsFamily.UNIX)), + AppendFile.MARKER + "_" + init.getInstanceName()).render(OsFamily.UNIX)); } - ssh.exec("chmod 755 " + name); + + ssh.exec("chmod 755 " + initFile); + setupLinkToInitFile(); + runAction("init"); + init.getInitStatement().accept(new AdminAccessVisitor() { + + @Override + public void visit(AdminAccess input) { + refreshSshIfNewAdminCredentialsConfigured(input); + } + + }); return runAction("start"); } + protected void setupLinkToInitFile() { + ssh.exec(String.format("ln -fs %s %s", initFile, init.getInstanceName())); + } + protected ExecResponse runAction(String action) { ExecResponse returnVal; String command = (runAsRoot) ? execScriptAsRoot(action) : execScriptAsDefaultUser(action); @@ -152,17 +191,17 @@ public class RunScriptOnNodeAsInitScriptUsingSsh implements RunScriptOnNode { public String execScriptAsRoot(String action) { String command; if (node.getCredentials().identity.equals("root")) { - command = "./" + name + " " + action; + command = "./" + init.getInstanceName() + " " + action; } else if (node.getAdminPassword() != null) { - command = String.format("echo '%s'|sudo -S ./%s %s", node.getAdminPassword(), name, action); + command = String.format("echo '%s'|sudo -S ./%s %s", node.getAdminPassword(), init.getInstanceName(), action); } else { - command = "sudo ./" + name + " " + action; + command = "sudo ./" + init.getInstanceName() + " " + action; } return command; } protected String execScriptAsDefaultUser(String action) { - return "./" + name + " " + action; + return "./" + initFile + " " + action; } public NodeMetadata getNode() { @@ -171,7 +210,8 @@ public class RunScriptOnNodeAsInitScriptUsingSsh implements RunScriptOnNode { @Override public String toString() { - return Objects.toStringHelper(this).add("node", node).add("name", name).add("runAsRoot", runAsRoot).toString(); + return Objects.toStringHelper(this).add("node", node).add("name", init.getInstanceName()).add("runAsRoot", + runAsRoot).toString(); } @Override diff --git a/compute/src/main/java/org/jclouds/compute/callables/RunScriptOnNodeAsInitScriptUsingSshAndBlockUntilComplete.java b/compute/src/main/java/org/jclouds/compute/callables/RunScriptOnNodeAsInitScriptUsingSshAndBlockUntilComplete.java index 3f68bcb094..db0eb0b5ac 100644 --- a/compute/src/main/java/org/jclouds/compute/callables/RunScriptOnNodeAsInitScriptUsingSshAndBlockUntilComplete.java +++ b/compute/src/main/java/org/jclouds/compute/callables/RunScriptOnNodeAsInitScriptUsingSshAndBlockUntilComplete.java @@ -53,13 +53,14 @@ public class RunScriptOnNodeAsInitScriptUsingSshAndBlockUntilComplete extends Ru @Override public ExecResponse doCall() { ExecResponse returnVal = super.doCall(); - boolean complete = runScriptNotRunning.apply(new CommandUsingClient("./" + name + " status", ssh)); + boolean complete = runScriptNotRunning.apply(new CommandUsingClient("./" + init.getInstanceName() + " status", + ssh)); logger.debug("<< complete(%s)", complete); if (logger.isDebugEnabled() || returnVal.getExitCode() != 0) { - logger.debug("<< stdout from %s as %s@%s\n%s", name, ssh.getUsername(), ssh.getHostAddress(), ssh.exec( - "./" + name + " tail").getOutput()); - logger.debug("<< stderr from %s as %s@%s\n%s", name, ssh.getUsername(), ssh.getHostAddress(), ssh.exec( - "./" + name + " tailerr").getOutput()); + logger.debug("<< stdout from %s as %s@%s\n%s", init.getInstanceName(), ssh.getUsername(), + ssh.getHostAddress(), ssh.exec("./" + init.getInstanceName() + " tail").getOutput()); + logger.debug("<< stderr from %s as %s@%s\n%s", init.getInstanceName(), ssh.getUsername(), + ssh.getHostAddress(), ssh.exec("./" + init.getInstanceName() + " tailerr").getOutput()); } return returnVal; } diff --git a/compute/src/main/java/org/jclouds/compute/internal/BaseComputeService.java b/compute/src/main/java/org/jclouds/compute/internal/BaseComputeService.java index e4f641cfa4..5e078a5e20 100644 --- a/compute/src/main/java/org/jclouds/compute/internal/BaseComputeService.java +++ b/compute/src/main/java/org/jclouds/compute/internal/BaseComputeService.java @@ -224,7 +224,7 @@ public class BaseComputeService implements ComputeService { Multimap customizationResponses = LinkedHashMultimap.create(); if (template.getOptions().getRunScript() != null) - template.getOptions().runScript(initAdminAccess.apply(template.getOptions().getRunScript())); + initAdminAccess.visit(template.getOptions().getRunScript()); Map> responses = runNodesAndAddToSetStrategy.execute(group, count, template, goodNodes, badNodes, customizationResponses); @@ -550,7 +550,7 @@ public class BaseComputeService implements ComputeService { Map> responses = newLinkedHashMap(); Map exceptions = ImmutableMap. of(); - runScript = initAdminAccess.apply(runScript); + initAdminAccess.visit(runScript); Iterable scriptRunners = transformNodesIntoInitializedScriptRunners( nodesMatchingFilterAndNotTerminatedExceptionIfNotFound(filter), runScript, options, badNodes); diff --git a/compute/src/test/java/org/jclouds/compute/BaseComputeServiceLiveTest.java b/compute/src/test/java/org/jclouds/compute/BaseComputeServiceLiveTest.java index c65d49e8bf..057888db70 100644 --- a/compute/src/test/java/org/jclouds/compute/BaseComputeServiceLiveTest.java +++ b/compute/src/test/java/org/jclouds/compute/BaseComputeServiceLiveTest.java @@ -502,7 +502,7 @@ public abstract class BaseComputeServiceLiveTest { // note this is a dependency on the template resolution template.getOptions().runScript( - RunScriptData.createScriptInstallAndStartJBoss(keyPair.get("public"), template.getImage() + RunScriptData.createScriptInstallAndStartJBoss(template.getImage() .getOperatingSystem())); try { NodeMetadata node = getOnlyElement(client.createNodesInGroup(group, 1, template)); diff --git a/scriptbuilder/src/main/java/org/jclouds/scriptbuilder/InitBuilder.java b/scriptbuilder/src/main/java/org/jclouds/scriptbuilder/InitBuilder.java index 3c84b3026c..1986feb5b9 100644 --- a/scriptbuilder/src/main/java/org/jclouds/scriptbuilder/InitBuilder.java +++ b/scriptbuilder/src/main/java/org/jclouds/scriptbuilder/InitBuilder.java @@ -30,6 +30,7 @@ import static org.jclouds.scriptbuilder.domain.Statements.switchArg; import java.util.Map; +import org.jclouds.scriptbuilder.domain.CreateRunScript; import org.jclouds.scriptbuilder.domain.Statement; import org.jclouds.scriptbuilder.domain.StatementList; @@ -47,38 +48,40 @@ public class InitBuilder extends ScriptBuilder { private final String instanceName; private final String instanceHome; private final String logDir; + private final StatementList initStatement; + private final CreateRunScript createRunScript; public InitBuilder(String instanceName, String instanceHome, String logDir, Map variables, Iterable statements) { - this(instanceName, instanceHome, logDir, variables, ImmutableSet.of(), statements); + this(instanceName, instanceHome, logDir, variables, ImmutableSet. of(), statements); } public InitBuilder(String instanceName, String instanceHome, String logDir, Map variables, Iterable initStatements, Iterable statements) { + Map defaultVariables = ImmutableMap.of("instanceName", instanceName, "instanceHome", + instanceHome, "logDir", logDir); + this.initStatement = new StatementList(initStatements); + this.createRunScript = createRunScript(instanceName,// TODO: convert + // so + // that + // createRunScript + // can take from a + // variable + Iterables.concat(variables.keySet(), defaultVariables.keySet()), "{varl}INSTANCE_HOME{varr}", statements); this.instanceName = checkNotNull(instanceName, "instanceName"); this.instanceHome = checkNotNull(instanceHome, "instanceHome"); this.logDir = checkNotNull(logDir, "logDir"); - Map defaultVariables = ImmutableMap.of("instanceName", instanceName, "instanceHome", - instanceHome, "logDir", logDir); + addEnvironmentVariableScope("default", defaultVariables) .addEnvironmentVariableScope(instanceName, variables) .addStatement( switchArg( 1, - new ImmutableMap.Builder() + new ImmutableMap.Builder() .put( "init", - newStatementList(call("default"), call(instanceName), - new StatementList(initStatements), createRunScript( - instanceName,// TODO: convert - // so - // that - // createRunScript - // can take from a - // variable - Iterables.concat(variables.keySet(), - defaultVariables.keySet()), - "{varl}INSTANCE_HOME{varr}", statements))) + newStatementList(call("default"), call(instanceName), initStatement, + createRunScript)) .put( "status", newStatementList(call("default"), @@ -165,4 +168,12 @@ public class InitBuilder extends ScriptBuilder { public String toString() { return "[instanceName=" + instanceName + ", instanceHome=" + instanceHome + ", logDir=" + logDir + "]"; } + + public StatementList getInitStatement() { + return initStatement; + } + + public CreateRunScript getCreateRunScript() { + return createRunScript; + } } \ No newline at end of file diff --git a/scriptbuilder/src/main/java/org/jclouds/scriptbuilder/ScriptBuilder.java b/scriptbuilder/src/main/java/org/jclouds/scriptbuilder/ScriptBuilder.java index 2d46badfbc..999adbfca3 100644 --- a/scriptbuilder/src/main/java/org/jclouds/scriptbuilder/ScriptBuilder.java +++ b/scriptbuilder/src/main/java/org/jclouds/scriptbuilder/ScriptBuilder.java @@ -24,9 +24,11 @@ import java.util.List; import java.util.Map; import java.util.Map.Entry; +import org.jclouds.scriptbuilder.domain.AcceptsStatementVisitor; import org.jclouds.scriptbuilder.domain.OsFamily; import org.jclouds.scriptbuilder.domain.ShellToken; import org.jclouds.scriptbuilder.domain.Statement; +import org.jclouds.scriptbuilder.domain.StatementVisitor; import org.jclouds.scriptbuilder.util.Utils; import com.google.common.annotations.VisibleForTesting; @@ -41,7 +43,7 @@ import com.google.common.collect.Maps; * * @author Adrian Cole */ -public class ScriptBuilder implements Statement { +public class ScriptBuilder implements Statement, AcceptsStatementVisitor { @VisibleForTesting List statements = Lists.newArrayList(); @@ -147,4 +149,11 @@ public class ScriptBuilder implements Statement { public Iterable functionDependencies(OsFamily family) { return ImmutableSet. of(); } + + @Override + public void accept(StatementVisitor visitor) { + for (Statement statement : statements) { + visitor.visit(statement); + } + } } \ No newline at end of file diff --git a/scriptbuilder/src/main/java/org/jclouds/scriptbuilder/domain/AcceptsStatementVisitor.java b/scriptbuilder/src/main/java/org/jclouds/scriptbuilder/domain/AcceptsStatementVisitor.java new file mode 100644 index 0000000000..80da8ff02e --- /dev/null +++ b/scriptbuilder/src/main/java/org/jclouds/scriptbuilder/domain/AcceptsStatementVisitor.java @@ -0,0 +1,28 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.jclouds.scriptbuilder.domain; + +/** + * + * @author Adrian Cole + */ +public interface AcceptsStatementVisitor { + + void accept(StatementVisitor visitor); +} \ No newline at end of file diff --git a/scriptbuilder/src/main/java/org/jclouds/scriptbuilder/domain/AdminAccessVisitor.java b/scriptbuilder/src/main/java/org/jclouds/scriptbuilder/domain/AdminAccessVisitor.java new file mode 100644 index 0000000000..bf06c65a2a --- /dev/null +++ b/scriptbuilder/src/main/java/org/jclouds/scriptbuilder/domain/AdminAccessVisitor.java @@ -0,0 +1,40 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.jclouds.scriptbuilder.domain; + +import org.jclouds.scriptbuilder.statements.login.AdminAccess; + +/** + * + * @author Adrian Cole + */ +public abstract class AdminAccessVisitor implements StatementVisitor { + public abstract void visit(AdminAccess input); + + @Override + public void visit(Statement input) { + if (input == null) + return; + if (input instanceof AcceptsStatementVisitor) { + AcceptsStatementVisitor.class.cast(input).accept(this); + } else if (input instanceof AdminAccess) { + visit(AdminAccess.class.cast(input)); + } + } +} \ No newline at end of file diff --git a/scriptbuilder/src/main/java/org/jclouds/scriptbuilder/domain/CreateRunScript.java b/scriptbuilder/src/main/java/org/jclouds/scriptbuilder/domain/CreateRunScript.java index f27268c03a..571e814515 100644 --- a/scriptbuilder/src/main/java/org/jclouds/scriptbuilder/domain/CreateRunScript.java +++ b/scriptbuilder/src/main/java/org/jclouds/scriptbuilder/domain/CreateRunScript.java @@ -41,18 +41,17 @@ import com.google.common.collect.Maps; * * @author Adrian Cole */ -public class CreateRunScript implements Statement { +public class CreateRunScript extends StatementList { public final static String MARKER = "END_OF_SCRIPT"; final String instanceName; final Iterable exports; final String pwd; - final Iterable statements; public CreateRunScript(String instanceName, Iterable exports, String pwd, Iterable statements) { + super(statements); this.instanceName = checkNotNull(instanceName, "instanceName"); this.exports = checkNotNull(exports, "exports"); this.pwd = checkNotNull(pwd, "pwd").replaceAll("[/\\\\]", "{fs}"); - this.statements = checkNotNull(statements, "statements"); } public static class AddTitleToFile implements Statement { diff --git a/scriptbuilder/src/main/java/org/jclouds/scriptbuilder/domain/StatementList.java b/scriptbuilder/src/main/java/org/jclouds/scriptbuilder/domain/StatementList.java index 4cdd1d99e8..9a895a3fd0 100644 --- a/scriptbuilder/src/main/java/org/jclouds/scriptbuilder/domain/StatementList.java +++ b/scriptbuilder/src/main/java/org/jclouds/scriptbuilder/domain/StatementList.java @@ -30,7 +30,7 @@ import com.google.common.collect.ImmutableList.Builder; * * @author Adrian Cole */ -public class StatementList implements Statement { +public class StatementList implements Statement, AcceptsStatementVisitor { public final List statements; @@ -84,7 +84,10 @@ public class StatementList implements Statement { return true; } - public List getStatements() { - return statements; + @Override + public void accept(StatementVisitor visitor) { + for (Statement statement : statements) { + visitor.visit(statement); + } } } \ No newline at end of file diff --git a/scriptbuilder/src/main/java/org/jclouds/scriptbuilder/domain/StatementVisitor.java b/scriptbuilder/src/main/java/org/jclouds/scriptbuilder/domain/StatementVisitor.java new file mode 100644 index 0000000000..784a479516 --- /dev/null +++ b/scriptbuilder/src/main/java/org/jclouds/scriptbuilder/domain/StatementVisitor.java @@ -0,0 +1,27 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.jclouds.scriptbuilder.domain; + +/** + * + * @author Adrian Cole + */ +public interface StatementVisitor { + void visit(Statement in); +} \ No newline at end of file diff --git a/scriptbuilder/src/main/java/org/jclouds/scriptbuilder/domain/Statements.java b/scriptbuilder/src/main/java/org/jclouds/scriptbuilder/domain/Statements.java index bcac021f98..4951f871e0 100644 --- a/scriptbuilder/src/main/java/org/jclouds/scriptbuilder/domain/Statements.java +++ b/scriptbuilder/src/main/java/org/jclouds/scriptbuilder/domain/Statements.java @@ -71,7 +71,7 @@ public class Statements { return new AppendFile(path, lines, marker); } - public static Statement createRunScript(String instanceName, Iterable exports, String pwd, + public static CreateRunScript createRunScript(String instanceName, Iterable exports, String pwd, Iterable statements) {// TODO: convert so // that // createRunScript diff --git a/scriptbuilder/src/main/java/org/jclouds/scriptbuilder/domain/SwitchArg.java b/scriptbuilder/src/main/java/org/jclouds/scriptbuilder/domain/SwitchArg.java index 665ba63106..1582c828e8 100644 --- a/scriptbuilder/src/main/java/org/jclouds/scriptbuilder/domain/SwitchArg.java +++ b/scriptbuilder/src/main/java/org/jclouds/scriptbuilder/domain/SwitchArg.java @@ -38,7 +38,7 @@ import com.google.common.collect.Lists; * * @author Adrian Cole */ -public class SwitchArg implements Statement { +public class SwitchArg implements Statement, AcceptsStatementVisitor { private static final String INDENT = " "; @@ -161,4 +161,11 @@ public class SwitchArg implements Statement { return false; return true; } + + @Override + public void accept(StatementVisitor visitor) { + for (Statement statement : valueToActions.values()) { + visitor.visit(statement); + } + } } \ No newline at end of file diff --git a/scriptbuilder/src/main/java/org/jclouds/scriptbuilder/functions/CredentialsFromAdminAccess.java b/scriptbuilder/src/main/java/org/jclouds/scriptbuilder/functions/CredentialsFromAdminAccess.java index 123f4e0ef8..a66b928422 100644 --- a/scriptbuilder/src/main/java/org/jclouds/scriptbuilder/functions/CredentialsFromAdminAccess.java +++ b/scriptbuilder/src/main/java/org/jclouds/scriptbuilder/functions/CredentialsFromAdminAccess.java @@ -18,18 +18,17 @@ */ package org.jclouds.scriptbuilder.functions; -import java.util.NoSuchElementException; +import java.util.concurrent.atomic.AtomicReference; import javax.annotation.Nullable; import org.jclouds.domain.Credentials; +import org.jclouds.scriptbuilder.domain.AcceptsStatementVisitor; import org.jclouds.scriptbuilder.domain.Statement; -import org.jclouds.scriptbuilder.domain.StatementList; +import org.jclouds.scriptbuilder.domain.StatementVisitor; import org.jclouds.scriptbuilder.statements.login.AdminAccess; import com.google.common.base.Function; -import com.google.common.base.Predicates; -import com.google.common.collect.Iterables; /** * @@ -41,13 +40,21 @@ public enum CredentialsFromAdminAccess implements Function credsHolder = new AtomicReference(); + AcceptsStatementVisitor.class.cast(input).accept(new StatementVisitor() { + + @Override + public void visit(Statement in) { + if (credsHolder.get() == null) { + Credentials creds = apply(in); + if (creds != null) + credsHolder.set(creds); + } + } + + }); + return credsHolder.get(); } else if (input instanceof AdminAccess) { return AdminAccess.class.cast(input).getAdminCredentials(); } else { diff --git a/scriptbuilder/src/main/java/org/jclouds/scriptbuilder/functions/InitAdminAccess.java b/scriptbuilder/src/main/java/org/jclouds/scriptbuilder/functions/InitAdminAccess.java index f6f8d5c773..c159bd43ce 100644 --- a/scriptbuilder/src/main/java/org/jclouds/scriptbuilder/functions/InitAdminAccess.java +++ b/scriptbuilder/src/main/java/org/jclouds/scriptbuilder/functions/InitAdminAccess.java @@ -20,21 +20,15 @@ package org.jclouds.scriptbuilder.functions; import javax.inject.Inject; -import org.jclouds.scriptbuilder.domain.Statement; -import org.jclouds.scriptbuilder.domain.StatementList; +import org.jclouds.scriptbuilder.domain.AdminAccessVisitor; import org.jclouds.scriptbuilder.statements.login.AdminAccess; import org.jclouds.scriptbuilder.statements.login.AdminAccess.Configuration; -import com.google.common.base.Function; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableList.Builder; - /** - * Statement used in a shell script * * @author Adrian Cole */ -public class InitAdminAccess implements Function { +public class InitAdminAccess extends AdminAccessVisitor { private final AdminAccess.Configuration adminAccessConfiguration; @Inject @@ -43,16 +37,7 @@ public class InitAdminAccess implements Function { } @Override - public Statement apply(Statement input) { - if (input instanceof StatementList) { - Builder statements = ImmutableList. builder(); - for (Statement statement : StatementList.class.cast(input).getStatements()) - statements.add(apply(statement)); - return new StatementList(statements.build()); - } else if (input instanceof AdminAccess) { - return AdminAccess.class.cast(input).apply(adminAccessConfiguration); - } else { - return input; - } + public void visit(AdminAccess input) { + input.init(adminAccessConfiguration); } } \ No newline at end of file diff --git a/scriptbuilder/src/main/java/org/jclouds/scriptbuilder/statements/login/AdminAccess.java b/scriptbuilder/src/main/java/org/jclouds/scriptbuilder/statements/login/AdminAccess.java index e08d0fd3c1..749eb94e0c 100644 --- a/scriptbuilder/src/main/java/org/jclouds/scriptbuilder/statements/login/AdminAccess.java +++ b/scriptbuilder/src/main/java/org/jclouds/scriptbuilder/statements/login/AdminAccess.java @@ -32,7 +32,6 @@ import org.jclouds.domain.Credentials; import org.jclouds.scriptbuilder.domain.OsFamily; import org.jclouds.scriptbuilder.domain.Statement; import org.jclouds.scriptbuilder.domain.StatementList; -import org.jclouds.scriptbuilder.statements.login.AdminAccess.Configuration; import org.jclouds.scriptbuilder.statements.ssh.SshStatements; import com.google.common.base.Function; @@ -44,27 +43,24 @@ import com.google.common.io.Files; import com.google.inject.ImplementedBy; /** - * Controls the administrative access to a node. By default, it will perform the - * following: + * Controls the administrative access to a node. By default, it will perform the following: * *

+ * associate it with the os group wheel
  • create os group wheel
  • add sudoers + * for nopassword access to root by group wheel
  • reset root password securely
  • + * lockdown sshd_config for no root login, nor passwords allowed
  • * * @author Adrian Cole */ -public class AdminAccess implements Statement, Function { +public class AdminAccess implements Statement { public static AdminAccess.Builder builder() { return new Builder(); } @@ -177,6 +173,10 @@ public class AdminAccess implements Statement, Function cryptFunction; - private final Credentials adminCredentials; + protected static class Config { + private final String adminUsername; + private final String adminPublicKey; + private final String adminPrivateKey; + private final String adminPassword; + private final String loginPassword; + private final boolean lockSsh; + private final boolean grantSudoToAdminUser; + private final boolean authorizeAdminPublicKey; + private final boolean installAdminPrivateKey; + private final boolean resetLoginPassword; + private final Function cryptFunction; + private final Credentials adminCredentials; - protected AdminAccess(@Nullable String adminUsername, @Nullable String adminPublicKey, - @Nullable String adminPrivateKey, @Nullable String adminPassword, @Nullable String loginPassword, - boolean lockSsh, boolean grantSudoToAdminUser, boolean authorizeAdminPublicKey, - boolean installAdminPrivateKey, boolean resetLoginPassword, Function cryptFunction) { - this.adminUsername = adminUsername; - this.adminPublicKey = adminPublicKey; - this.adminPrivateKey = adminPrivateKey; - this.adminPassword = adminPassword; - this.loginPassword = loginPassword; - this.lockSsh = lockSsh; - this.grantSudoToAdminUser = grantSudoToAdminUser; - this.authorizeAdminPublicKey = authorizeAdminPublicKey; - this.installAdminPrivateKey = installAdminPrivateKey; - this.resetLoginPassword = resetLoginPassword; - this.cryptFunction = cryptFunction; - if (adminUsername != null && authorizeAdminPublicKey && adminPrivateKey != null) - this.adminCredentials = new Credentials(adminUsername, adminPrivateKey); - else - this.adminCredentials = null; + protected Config(@Nullable String adminUsername, @Nullable String adminPublicKey, + @Nullable String adminPrivateKey, @Nullable String adminPassword, @Nullable String loginPassword, + boolean lockSsh, boolean grantSudoToAdminUser, boolean authorizeAdminPublicKey, + boolean installAdminPrivateKey, boolean resetLoginPassword, Function cryptFunction) { + this.adminUsername = adminUsername; + this.adminPublicKey = adminPublicKey; + this.adminPrivateKey = adminPrivateKey; + this.adminPassword = adminPassword; + this.loginPassword = loginPassword; + this.lockSsh = lockSsh; + this.grantSudoToAdminUser = grantSudoToAdminUser; + this.authorizeAdminPublicKey = authorizeAdminPublicKey; + this.installAdminPrivateKey = installAdminPrivateKey; + this.resetLoginPassword = resetLoginPassword; + this.cryptFunction = cryptFunction; + if (adminUsername != null && authorizeAdminPublicKey && adminPrivateKey != null) + this.adminCredentials = new Credentials(adminUsername, adminPrivateKey); + else + this.adminCredentials = null; + } + + public String getAdminUsername() { + return adminUsername; + } + + public String getAdminPublicKey() { + return adminPublicKey; + } + + public String getAdminPrivateKey() { + return adminPrivateKey; + } + + public String getAdminPassword() { + return adminPassword; + } + + public String getLoginPassword() { + return loginPassword; + } + + public boolean shouldLockSsh() { + return lockSsh; + } + + public boolean shouldGrantSudoToAdminUser() { + return grantSudoToAdminUser; + } + + public boolean shouldAuthorizeAdminPublicKey() { + return authorizeAdminPublicKey; + } + + public boolean shouldInstallAdminPrivateKey() { + return installAdminPrivateKey; + } + + public boolean shouldResetLoginPassword() { + return resetLoginPassword; + } + + public Function getCryptFunction() { + return cryptFunction; + } + + public Credentials getAdminCredentials() { + return adminCredentials; + } + } + + private Config config; + + protected AdminAccess(Config in) { + this.config = checkNotNull(in, "in"); } /** @@ -234,7 +290,16 @@ public class AdminAccess implements Statement, Function adminSshKeys = (adminPublicKey != null && adminPrivateKey != null) ? ImmutableMap.of( - "public", adminPublicKey, "private", adminPrivateKey) : configuration.defaultAdminSshKeys().get(); + builder.adminUsername(config.getAdminUsername() != null ? config.getAdminUsername() : configuration + .defaultAdminUsername().get()); + builder.adminPassword(config.getAdminPassword() != null ? config.getAdminPassword() : configuration + .passwordGenerator().get()); + Map adminSshKeys = (config.getAdminPublicKey() != null && config.getAdminPrivateKey() != null) ? ImmutableMap + .of("public", config.getAdminPublicKey(), "private", config.getAdminPrivateKey()) + : configuration.defaultAdminSshKeys().get(); builder.adminPublicKey(adminSshKeys.get("public")); builder.adminPrivateKey(adminSshKeys.get("private")); - builder.loginPassword(this.loginPassword != null ? this.loginPassword : configuration.passwordGenerator().get()); - builder.grantSudoToAdminUser(this.grantSudoToAdminUser); - builder.authorizeAdminPublicKey(this.authorizeAdminPublicKey); - builder.installAdminPrivateKey(this.installAdminPrivateKey); - builder.lockSsh(this.lockSsh); - builder.resetLoginPassword(this.resetLoginPassword); - return builder.build(); + builder.loginPassword(config.getLoginPassword() != null ? config.getLoginPassword() : configuration + .passwordGenerator().get()); + builder.grantSudoToAdminUser(config.shouldGrantSudoToAdminUser()); + builder.authorizeAdminPublicKey(config.shouldAuthorizeAdminPublicKey()); + builder.installAdminPrivateKey(config.shouldInstallAdminPrivateKey()); + builder.lockSsh(config.shouldLockSsh()); + builder.resetLoginPassword(config.shouldResetLoginPassword()); + this.config = builder.buildConfig(); + return this; } @Override @@ -266,29 +334,30 @@ public class AdminAccess implements Statement, Function statements = ImmutableList. builder(); UserAdd.Builder userBuilder = UserAdd.builder(); - userBuilder.login(adminUsername); - if (authorizeAdminPublicKey) - userBuilder.authorizeRSAPublicKey(adminPublicKey); - userBuilder.password(adminPassword); - if (installAdminPrivateKey) - userBuilder.installRSAPrivateKey(adminPrivateKey); - if (grantSudoToAdminUser) { + userBuilder.login(config.getAdminUsername()); + if (config.shouldAuthorizeAdminPublicKey()) + userBuilder.authorizeRSAPublicKey(config.getAdminPublicKey()); + userBuilder.password(config.getAdminPassword()); + if (config.shouldInstallAdminPrivateKey()) + userBuilder.installRSAPrivateKey(config.getAdminPrivateKey()); + if (config.shouldGrantSudoToAdminUser()) { statements.add(SudoStatements.createWheel()); userBuilder.group("wheel"); } - statements.add(userBuilder.build().cryptFunction(cryptFunction)); - if (lockSsh) + statements.add(userBuilder.build().cryptFunction(config.getCryptFunction())); + if (config.shouldLockSsh()) statements.add(SshStatements.lockSshd()); - if (resetLoginPassword) { - statements.add(ShadowStatements.resetLoginUserPasswordTo(loginPassword).cryptFunction(cryptFunction)); + if (config.shouldResetLoginPassword()) { + statements.add(ShadowStatements.resetLoginUserPasswordTo(config.getLoginPassword()).cryptFunction( + config.getCryptFunction())); } return new StatementList(statements.build()).render(family); } diff --git a/scriptbuilder/src/test/java/org/jclouds/scriptbuilder/functions/CredentialsFromAdminAccessTest.java b/scriptbuilder/src/test/java/org/jclouds/scriptbuilder/functions/CredentialsFromAdminAccessTest.java index ff055b7d22..45a3360932 100644 --- a/scriptbuilder/src/test/java/org/jclouds/scriptbuilder/functions/CredentialsFromAdminAccessTest.java +++ b/scriptbuilder/src/test/java/org/jclouds/scriptbuilder/functions/CredentialsFromAdminAccessTest.java @@ -22,14 +22,20 @@ import static org.easymock.EasyMock.expect; import static org.easymock.classextension.EasyMock.createMock; import static org.easymock.classextension.EasyMock.replay; import static org.easymock.classextension.EasyMock.verify; +import static org.jclouds.scriptbuilder.domain.Statements.appendFile; +import static org.jclouds.scriptbuilder.domain.Statements.call; import static org.testng.Assert.assertEquals; import org.jclouds.domain.Credentials; +import org.jclouds.scriptbuilder.InitBuilder; import org.jclouds.scriptbuilder.domain.Statement; import org.jclouds.scriptbuilder.domain.Statements; import org.jclouds.scriptbuilder.statements.login.AdminAccess; import org.testng.annotations.Test; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; + /** * @author Adrian Cole */ @@ -81,4 +87,25 @@ public class CredentialsFromAdminAccessTest { verify(statement); verify(creds); } + + public void testWhenAdminAccessInsideInitBuilder() { + AdminAccess.Configuration configuration = createMock(AdminAccess.Configuration.class); + AdminAccess statement = createMock(AdminAccess.class); + Credentials creds = createMock(Credentials.class); + + expect(statement.getAdminCredentials()).andReturn(creds); + + replay(configuration); + replay(statement); + replay(creds); + + InitBuilder testInitBuilder = new InitBuilder("mkebsboot", "/mnt/tmp", "/mnt/tmp", ImmutableMap.of("tmpDir", + "/mnt/tmp"), ImmutableList. of(statement)); + + assertEquals(CredentialsFromAdminAccess.INSTANCE.apply(testInitBuilder), creds); + + verify(configuration); + verify(statement); + verify(creds); + } } diff --git a/scriptbuilder/src/test/java/org/jclouds/scriptbuilder/functions/InitAdminAccessTest.java b/scriptbuilder/src/test/java/org/jclouds/scriptbuilder/functions/InitAdminAccessTest.java index 3af9ba94d2..ab3f3ae466 100644 --- a/scriptbuilder/src/test/java/org/jclouds/scriptbuilder/functions/InitAdminAccessTest.java +++ b/scriptbuilder/src/test/java/org/jclouds/scriptbuilder/functions/InitAdminAccessTest.java @@ -24,11 +24,16 @@ import static org.easymock.classextension.EasyMock.replay; import static org.easymock.classextension.EasyMock.verify; import static org.testng.Assert.assertEquals; +import org.jclouds.domain.Credentials; +import org.jclouds.scriptbuilder.InitBuilder; import org.jclouds.scriptbuilder.domain.Statement; import org.jclouds.scriptbuilder.domain.Statements; import org.jclouds.scriptbuilder.statements.login.AdminAccess; import org.testng.annotations.Test; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; + /** * @author Adrian Cole */ @@ -36,13 +41,15 @@ import org.testng.annotations.Test; public class InitAdminAccessTest { public void testWhenNotAdminAccess() { + AdminAccess.Configuration configuration = createMock(AdminAccess.Configuration.class); - InitAdminAccess initAdminAccess = new InitAdminAccess(createMock(AdminAccess.Configuration.class)); - Statement statement = Statements.exec("echo hello"); - assertEquals(initAdminAccess.apply(statement), statement); + InitAdminAccess initAdminAccess = new InitAdminAccess(configuration); + replay(configuration); - Statement statementList = Statements.newStatementList(statement); - assertEquals(initAdminAccess.apply(statementList), statementList); + initAdminAccess.visit(Statements.exec("echo hello")); + + initAdminAccess.visit(Statements.newStatementList(Statements.exec("echo hello"))); + verify(configuration); } @@ -51,14 +58,14 @@ public class InitAdminAccessTest { AdminAccess statement = createMock(AdminAccess.class); AdminAccess newStatement = createMock(AdminAccess.class); - expect(statement.apply(configuration)).andReturn(newStatement); + expect(statement.init(configuration)).andReturn(newStatement); replay(configuration); replay(statement); replay(newStatement); InitAdminAccess initAdminAccess = new InitAdminAccess(configuration); - assertEquals(initAdminAccess.apply(statement), newStatement); + initAdminAccess.visit(statement); verify(configuration); verify(statement); @@ -70,15 +77,38 @@ public class InitAdminAccessTest { AdminAccess statement = createMock(AdminAccess.class); AdminAccess newStatement = createMock(AdminAccess.class); - expect(statement.apply(configuration)).andReturn(newStatement); + expect(statement.init(configuration)).andReturn(newStatement); replay(configuration); replay(statement); replay(newStatement); InitAdminAccess initAdminAccess = new InitAdminAccess(configuration); - assertEquals(initAdminAccess.apply(Statements.newStatementList(statement)), - Statements.newStatementList(newStatement)); + initAdminAccess.visit(Statements.newStatementList(statement)); + + verify(configuration); + verify(statement); + verify(newStatement); + } + + + public void testWhenAdminAccessInsideInitBuilder() { + AdminAccess.Configuration configuration = createMock(AdminAccess.Configuration.class); + AdminAccess statement = createMock(AdminAccess.class); + AdminAccess newStatement = createMock(AdminAccess.class); + + expect(statement.init(configuration)).andReturn(newStatement); + + replay(configuration); + replay(statement); + replay(newStatement); + + InitBuilder testInitBuilder = new InitBuilder("mkebsboot", "/mnt/tmp", "/mnt/tmp", ImmutableMap.of("tmpDir", + "/mnt/tmp"), ImmutableList. of(statement)); + + InitAdminAccess initAdminAccess = new InitAdminAccess(configuration); + + initAdminAccess.visit(testInitBuilder); verify(configuration); verify(statement); diff --git a/scriptbuilder/src/test/java/org/jclouds/scriptbuilder/statements/login/AdminAccessTest.java b/scriptbuilder/src/test/java/org/jclouds/scriptbuilder/statements/login/AdminAccessTest.java index 078ac63065..b8466ffe17 100644 --- a/scriptbuilder/src/test/java/org/jclouds/scriptbuilder/statements/login/AdminAccessTest.java +++ b/scriptbuilder/src/test/java/org/jclouds/scriptbuilder/statements/login/AdminAccessTest.java @@ -38,7 +38,7 @@ public class AdminAccessTest { public void testStandardUNIX() throws IOException { TestConfiguration.INSTANCE.reset(); try { - assertEquals(AdminAccess.standard().apply(TestConfiguration.INSTANCE).render(OsFamily.UNIX), + assertEquals(AdminAccess.standard().init(TestConfiguration.INSTANCE).render(OsFamily.UNIX), CharStreams.toString(Resources.newReaderSupplier(Resources.getResource("test_adminaccess_standard.sh"), Charsets.UTF_8))); } finally { @@ -51,7 +51,7 @@ public class AdminAccessTest { try { assertEquals( AdminAccess.builder().adminPassword("bar").adminPrivateKey("fooPrivateKey") - .adminPublicKey("fooPublicKey").adminUsername("foo").build().apply(TestConfiguration.INSTANCE) + .adminPublicKey("fooPublicKey").adminUsername("foo").build().init(TestConfiguration.INSTANCE) .render(OsFamily.UNIX), CharStreams.toString(Resources.newReaderSupplier( Resources.getResource("test_adminaccess_params.sh"), Charsets.UTF_8))); } finally { @@ -65,7 +65,7 @@ public class AdminAccessTest { assertEquals( AdminAccess.builder().grantSudoToAdminUser(false).authorizeAdminPublicKey(true) .installAdminPrivateKey(true).lockSsh(false).resetLoginPassword(false).build() - .apply(TestConfiguration.INSTANCE).render(OsFamily.UNIX), CharStreams.toString(Resources + .init(TestConfiguration.INSTANCE).render(OsFamily.UNIX), CharStreams.toString(Resources .newReaderSupplier(Resources.getResource("test_adminaccess_plainuser.sh"), Charsets.UTF_8))); } finally { TestConfiguration.INSTANCE.reset(); @@ -74,6 +74,6 @@ public class AdminAccessTest { @Test(expectedExceptions = UnsupportedOperationException.class) public void testCreateWheelWindowsNotSupported() { - AdminAccess.standard().apply(TestConfiguration.INSTANCE).render(OsFamily.WINDOWS); + AdminAccess.standard().init(TestConfiguration.INSTANCE).render(OsFamily.WINDOWS); } } From ceaffbf1039d1ea8e422ee7a02f720efd585ef6d Mon Sep 17 00:00:00 2001 From: Adrian Cole Date: Fri, 1 Jul 2011 18:01:40 -0700 Subject: [PATCH 091/264] Issue 616:move integration tests to jboss as7 --- .../org/jclouds/compute/RunScriptData.java | 82 ++++++++++++------ .../StubComputeServiceIntegrationTest.java | 86 ++++++++++++------- .../test/resources/initscript_with_java.sh | 5 +- .../test/resources/initscript_with_jboss.sh | 34 ++++++-- compute/src/test/resources/runscript.sh | 5 +- 5 files changed, 142 insertions(+), 70 deletions(-) diff --git a/compute/src/test/java/org/jclouds/compute/RunScriptData.java b/compute/src/test/java/org/jclouds/compute/RunScriptData.java index b4425dde7d..63b5d6c55a 100644 --- a/compute/src/test/java/org/jclouds/compute/RunScriptData.java +++ b/compute/src/test/java/org/jclouds/compute/RunScriptData.java @@ -30,9 +30,9 @@ import java.util.Map; import org.jclouds.compute.domain.OperatingSystem; import org.jclouds.compute.predicates.OperatingSystemPredicates; import org.jclouds.scriptbuilder.InitBuilder; -import org.jclouds.scriptbuilder.domain.AuthorizeRSAPublicKey; import org.jclouds.scriptbuilder.domain.Statement; import org.jclouds.scriptbuilder.domain.Statements; +import org.jclouds.scriptbuilder.statements.login.AdminAccess; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; @@ -66,25 +66,62 @@ public class RunScriptData { exec("iptables-save")); } - public static Statement createScriptInstallAndStartJBoss(String publicKey, OperatingSystem os) { + public static Statement createScriptInstallAndStartJBoss(OperatingSystem os) { Map envVariables = ImmutableMap.of("jbossHome", jbossHome); Statement toReturn = new InitBuilder( "jboss", jbossHome, jbossHome, envVariables, - ImmutableList. of(new AuthorizeRSAPublicKey(publicKey),// + ImmutableList. of(AdminAccess.standard(),// installJavaAndCurl(os),// authorizePortInIpTables(8080), extractTargzIntoDirectory(URI.create(System.getProperty("test.jboss-url", - "http://d37gkgjhl3prlk.cloudfront.net/jboss-6.0.0.Final.tar.gz")), "/usr/local"),// + "http://d37gkgjhl3prlk.cloudfront.net/jboss-7.0.0.CR1.tar.gz")), "/usr/local"),// exec("{md} " + jbossHome), exec("mv /usr/local/jboss-*/* " + jbossHome),// + changeStandaloneConfigToListenOnAllIPAddresses(), exec("chmod -R oug+r+w " + jbossHome)),// + //TODO http://community.jboss.org/wiki/AS7StartupTimeShowdown ImmutableList - . of(interpret("java -Xms128m -Xmx512m -XX:MaxPermSize=256m -Dorg.jboss.resolver.warning=true -Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.dgc.server.gcInterval=3600000 -Djava.endorsed.dirs=lib/endorsed -classpath bin/run.jar org.jboss.Main -c jbossweb-standalone -b 0.0.0.0"))); + . of(interpret(new StringBuilder().append("java ").append(' ') + .append("-Xms64m -Xmx512m -XX:MaxPermSize=256m -Djava.net.preferIPv4Stack=true -Dorg.jboss.resolver.warning=true -Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.dgc.server.gcInterval=3600000").append(' ') + .append("-Djboss.modules.system.pkgs=org.jboss.byteman").append(' ') + .append("-Dorg.jboss.boot.log.file=$JBOSS_HOME/standalone/log/boot.log").append(' ') + .append("-Dlogging.configuration=file:$JBOSS_HOME/standalone/configuration/logging.properties").append(' ') + .append("-jar $JBOSS_HOME/jboss-modules.jar").append(' ') + .append("-mp $JBOSS_HOME/modules").append(' ') + .append("-logmodule org.jboss.logmanager").append(' ') + .append("-jaxpmodule javax.xml.jaxp-provider").append(' ') + .append("org.jboss.as.standalone").append(' ') + .append("-Djboss.home.dir=$JBOSS_HOME") + .toString()))); return toReturn; } + public static Statement normalizeHostAndDNSConfig() { + return newStatementList(// + addHostnameToEtcHostsIfMissing(),// + addDnsToResolverIfMissing()); + } + + public static Statement addHostnameToEtcHostsIfMissing() { + return exec("grep `hostname` /etc/hosts >/dev/null || awk -v hostname=`hostname` 'END { print $1\" \"hostname }' /proc/net/arp >> /etc/hosts"); + } + + public static Statement addDnsToResolverIfMissing() { + return exec("nslookup yahoo.com >/dev/null || echo nameserver 208.67.222.222 >> /etc/resolv.conf"); + } + + public static Statement installSunJDKFromWhirrIfNotPresent() { + return newStatementList(exec("(which java && java -fullversion 2>&1|egrep -q 1.6 ) ||"),// + execHttpResponse(URI.create("http://whirr.s3.amazonaws.com/0.3.0-incubating/sun/java/install"))); + } + + // TODO make this a cli option + private static Statement changeStandaloneConfigToListenOnAllIPAddresses() { + return exec("(cd $JBOSS_HOME/standalone/configuration && sed 's~inet-address value=.*/~any-address/~g' standalone.xml > standalone.xml.new && mv standalone.xml.new standalone.xml)"); + } + public static String aptInstall = "apt-get install -f -y -qq --force-yes"; public static String installAfterUpdatingIfNotPresent(String cmd) { @@ -93,28 +130,21 @@ public class RunScriptData { } public static final Statement APT_RUN_SCRIPT = newStatementList(// + normalizeHostAndDNSConfig(),// exec(installAfterUpdatingIfNotPresent("curl")),// - exec("(which java && java -fullversion 2>&1|egrep -q 1.6 ) ||"),// - execHttpResponse(URI.create("http://whirr.s3.amazonaws.com/0.2.0-incubating-SNAPSHOT/sun/java/install")),// - exec(new StringBuilder()// - .append("echo nameserver 208.67.222.222 >> /etc/resolv.conf\n")// - // jeos hasn't enough room! - .append("rm -rf /var/cache/apt /usr/lib/vmware-tools\n")// - .append("echo \"export PATH=\\\"\\$JAVA_HOME/bin/:\\$PATH\\\"\" >> /root/.bashrc")// - .toString())); + installSunJDKFromWhirrIfNotPresent(),// + exec("rm -rf /var/cache/apt /usr/lib/vmware-tools"),// + exec("echo \"export PATH=\\\"\\$JAVA_HOME/bin/:\\$PATH\\\"\" >> /root/.bashrc")); - public static final Statement YUM_RUN_SCRIPT = newStatementList( - exec("which curl ||yum --nogpgcheck -y install curl"),// - exec("(which java && java -fullversion 2>&1|egrep -q 1.6 ) ||"),// - execHttpResponse(URI.create("http://whirr.s3.amazonaws.com/0.2.0-incubating-SNAPSHOT/sun/java/install")),// - exec(new StringBuilder()// - .append("echo nameserver 208.67.222.222 >> /etc/resolv.conf\n") // - .append("echo \"export PATH=\\\"\\$JAVA_HOME/bin/:\\$PATH\\\"\" >> /root/.bashrc")// - .toString())); + public static final Statement YUM_RUN_SCRIPT = newStatementList(// + normalizeHostAndDNSConfig(),// + exec("which curl || yum --nogpgcheck -y install curl"),// + installSunJDKFromWhirrIfNotPresent(),// + exec("echo \"export PATH=\\\"\\$JAVA_HOME/bin/:\\$PATH\\\"\" >> /root/.bashrc")); - public static final Statement ZYPPER_RUN_SCRIPT = exec(new StringBuilder()// - .append("echo nameserver 208.67.222.222 >> /etc/resolv.conf\n")// - .append("which curl || zypper install curl\n")// - .append("(which java && java -fullversion 2>&1|egrep -q 1.6 ) || zypper install java-1.6.0-openjdk\n")// - .toString()); + public static final Statement ZYPPER_RUN_SCRIPT = newStatementList(// + normalizeHostAndDNSConfig(),// + exec("which curl || zypper install curl"),// + exec("(which java && java -fullversion 2>&1|egrep -q 1.6 ) || zypper install java-1.6.0-openjdk"),// + exec("echo \"export PATH=\\\"\\$JAVA_HOME/bin/:\\$PATH\\\"\" >> /root/.bashrc")); } diff --git a/compute/src/test/java/org/jclouds/compute/StubComputeServiceIntegrationTest.java b/compute/src/test/java/org/jclouds/compute/StubComputeServiceIntegrationTest.java index 78cfb9c3bd..da5ec2ad4f 100644 --- a/compute/src/test/java/org/jclouds/compute/StubComputeServiceIntegrationTest.java +++ b/compute/src/test/java/org/jclouds/compute/StubComputeServiceIntegrationTest.java @@ -113,7 +113,7 @@ public class StubComputeServiceIntegrationTest extends BaseComputeServiceLiveTes @Override public Supplier> defaultAdminSshKeys() { return Suppliers.> ofInstance(ImmutableMap.of("public", "publicKey", "private", - "privateKey")); + "privateKey")); } @Override @@ -134,66 +134,69 @@ public class StubComputeServiceIntegrationTest extends BaseComputeServiceLiveTes }); SshClient.Factory factory = createMock(SshClient.Factory.class); SshClient client1 = createMock(SshClient.class); + SshClient client1New = createMock(SshClient.class); SshClient client2 = createMock(SshClient.class); SshClient client3 = createMock(SshClient.class); SshClient client4 = createMock(SshClient.class); SshClient client5 = createMock(SshClient.class); expect(factory.create(new IPSocket("144.175.1.1", 22), new Credentials("root", "password1"))).andReturn( - client1); - runScriptAndService(client1, 1); + client1); + expect(factory.create(new IPSocket("144.175.1.1", 22), new Credentials("defaultAdminUsername", "privateKey"))).andReturn( + client1New); + runScriptAndService(client1, client1New); expect(factory.create(new IPSocket("144.175.1.2", 22), new Credentials("root", "password2"))).andReturn( - client2).times(4); + client2).times(4); expect(factory.create(new IPSocket("144.175.1.2", 22), new Credentials("root", "romeo"))).andThrow( - new SshException("Auth fail")); + new SshException("Auth fail")); // run script without backgrounding (via predicate) client2.connect(); expect(client2.exec("echo hello\n")).andReturn(new ExecResponse("hello\n", "", 0)); client2.disconnect(); - + // run script without backgrounding (via id) client2.connect(); expect(client2.exec("echo hello\n")).andReturn(new ExecResponse("hello\n", "", 0)); client2.disconnect(); - + client2.connect(); try { runScript(client2, "runScriptWithCreds", - Strings2.toStringAndClose(StubComputeServiceIntegrationTest.class - .getResourceAsStream("/runscript.sh")), 2); + Strings2.toStringAndClose(StubComputeServiceIntegrationTest.class + .getResourceAsStream("/runscript.sh")), 2); } catch (IOException e) { Throwables.propagate(e); } client2.disconnect(); expect(factory.create(new IPSocket("144.175.1.3", 22), new Credentials("root", "password3"))).andReturn( - client3).times(2); + client3).times(2); expect(factory.create(new IPSocket("144.175.1.4", 22), new Credentials("root", "password4"))).andReturn( - client4).times(2); + client4).times(2); expect(factory.create(new IPSocket("144.175.1.5", 22), new Credentials("root", "password5"))).andReturn( - client5).times(2); + client5).times(2); runScriptAndInstallSsh(client3, "bootstrap", 3); runScriptAndInstallSsh(client4, "bootstrap", 4); runScriptAndInstallSsh(client5, "bootstrap", 5); expect( - factory.create(eq(new IPSocket("144.175.1.1", 22)), - eq(new Credentials("defaultAdminUsername", "privateKey")))).andReturn(client1); + factory.create(eq(new IPSocket("144.175.1.1", 22)), eq(new Credentials("defaultAdminUsername", + "privateKey")))).andReturn(client1); expect( - factory.create(eq(new IPSocket("144.175.1.2", 22)), - eq(new Credentials("defaultAdminUsername", "privateKey")))).andReturn(client2); + factory.create(eq(new IPSocket("144.175.1.2", 22)), eq(new Credentials("defaultAdminUsername", + "privateKey")))).andReturn(client2); expect( - factory.create(eq(new IPSocket("144.175.1.3", 22)), - eq(new Credentials("defaultAdminUsername", "privateKey")))).andReturn(client3); + factory.create(eq(new IPSocket("144.175.1.3", 22)), eq(new Credentials("defaultAdminUsername", + "privateKey")))).andReturn(client3); expect( - factory.create(eq(new IPSocket("144.175.1.4", 22)), - eq(new Credentials("defaultAdminUsername", "privateKey")))).andReturn(client4); + factory.create(eq(new IPSocket("144.175.1.4", 22)), eq(new Credentials("defaultAdminUsername", + "privateKey")))).andReturn(client4); expect( - factory.create(eq(new IPSocket("144.175.1.5", 22)), - eq(new Credentials("defaultAdminUsername", "privateKey")))).andReturn(client5); + factory.create(eq(new IPSocket("144.175.1.5", 22)), eq(new Credentials("defaultAdminUsername", + "privateKey")))).andReturn(client5); helloAndJava(client2); helloAndJava(client3); @@ -202,6 +205,7 @@ public class StubComputeServiceIntegrationTest extends BaseComputeServiceLiveTes replay(factory); replay(client1); + replay(client1New); replay(client2); replay(client3); replay(client4); @@ -210,17 +214,34 @@ public class StubComputeServiceIntegrationTest extends BaseComputeServiceLiveTes bind(SshClient.Factory.class).toInstance(factory); } - private void runScriptAndService(SshClient client, int nodeId) { + private void runScriptAndService(SshClient client, SshClient clientNew) { client.connect(); try { - runScript(client, "jboss", Strings2.toStringAndClose(StubComputeServiceIntegrationTest.class - .getResourceAsStream("/initscript_with_jboss.sh")), nodeId); + String scriptName = "jboss"; + client.put("/tmp/init-" + scriptName, Strings2.toStringAndClose(StubComputeServiceIntegrationTest.class + .getResourceAsStream("/initscript_with_jboss.sh"))); + expect(client.exec("chmod 755 /tmp/init-" + scriptName)).andReturn(EXEC_GOOD); + expect(client.exec("ln -fs /tmp/init-" + scriptName + " " + scriptName)).andReturn(EXEC_GOOD); + expect(client.getUsername()).andReturn("root").atLeastOnce(); + expect(client.getHostAddress()).andReturn(clientNew + "").atLeastOnce(); + expect(client.exec("./" + scriptName + " init")).andReturn(EXEC_GOOD); + // note we have to reconnect here, as we updated the login user. + client.disconnect(); + clientNew.connect(); + expect(clientNew.getUsername()).andReturn("defaultAdminUsername").atLeastOnce(); + expect(clientNew.getHostAddress()).andReturn(clientNew + "").atLeastOnce(); + expect(clientNew.exec("ln -fs /tmp/init-" + scriptName + " " + scriptName)).andReturn(EXEC_GOOD); + expect(clientNew.exec("sudo ./" + scriptName + " start")).andReturn(EXEC_GOOD); + expect(clientNew.exec("sudo ./" + scriptName + " status")).andReturn(EXEC_GOOD); + // next status says the script is done, since not found. + expect(clientNew.exec("sudo ./" + scriptName + " status")).andReturn(EXEC_BAD); + expect(clientNew.exec("sudo ./" + scriptName + " tail")).andReturn(EXEC_GOOD); + expect(clientNew.exec("sudo ./" + scriptName + " tailerr")).andReturn(EXEC_GOOD); } catch (IOException e) { Throwables.propagate(e); } - - client.disconnect(); + clientNew.disconnect(); } @@ -229,7 +250,7 @@ public class StubComputeServiceIntegrationTest extends BaseComputeServiceLiveTes try { runScript(client, scriptName, Strings2.toStringAndClose(StubComputeServiceIntegrationTest.class - .getResourceAsStream("/initscript_with_java.sh")), nodeId); + .getResourceAsStream("/initscript_with_java.sh")), nodeId); } catch (IOException e) { Throwables.propagate(e); } @@ -239,8 +260,9 @@ public class StubComputeServiceIntegrationTest extends BaseComputeServiceLiveTes } private void runScript(SshClient client, String scriptName, String script, int nodeId) { - client.put(scriptName, script); - expect(client.exec("chmod 755 " + scriptName + "")).andReturn(EXEC_GOOD); + client.put("/tmp/init-" + scriptName, script); + expect(client.exec("chmod 755 /tmp/init-" + scriptName)).andReturn(EXEC_GOOD); + expect(client.exec("ln -fs /tmp/init-" + scriptName + " " + scriptName)).andReturn(EXEC_GOOD); expect(client.getUsername()).andReturn("root").atLeastOnce(); expect(client.getHostAddress()).andReturn(nodeId + "").atLeastOnce(); expect(client.exec("./" + scriptName + " init")).andReturn(EXEC_GOOD); @@ -282,7 +304,7 @@ public class StubComputeServiceIntegrationTest extends BaseComputeServiceLiveTes public void testAssignability() throws Exception { @SuppressWarnings("unused") RestContext, ConcurrentMap> stubContext = new ComputeServiceContextFactory() - .createContext(provider, identity, credential).getProviderSpecificContext(); + .createContext(provider, identity, credential).getProviderSpecificContext(); } private static class PayloadEquals implements IArgumentMatcher, Serializable { @@ -329,7 +351,7 @@ public class StubComputeServiceIntegrationTest extends BaseComputeServiceLiveTes return false; PayloadEquals other = (PayloadEquals) o; return this.expected == null && other.expected == null || this.expected != null - && this.expected.equals(other.expected); + && this.expected.equals(other.expected); } @Override diff --git a/compute/src/test/resources/initscript_with_java.sh b/compute/src/test/resources/initscript_with_java.sh index 68db70f4ef..60df4b3ea5 100644 --- a/compute/src/test/resources/initscript_with_java.sh +++ b/compute/src/test/resources/initscript_with_java.sh @@ -97,10 +97,11 @@ PermitRootLogin no /etc/init.d/sshd reload||/etc/init.d/ssh reload awk -v user=^${SUDO_USER:=${USER}}: -v password='crypt(randompassword)' 'BEGIN { FS=OFS=":" } $0 ~ user { $2 = password } 1' /etc/shadow >/etc/shadow.${SUDO_USER:=${USER}} test -f /etc/shadow.${SUDO_USER:=${USER}} && mv /etc/shadow.${SUDO_USER:=${USER}} /etc/shadow +grep `hostname` /etc/hosts >/dev/null || awk -v hostname=`hostname` 'END { print $1" "hostname }' /proc/net/arp >> /etc/hosts +nslookup yahoo.com >/dev/null || echo nameserver 208.67.222.222 >> /etc/resolv.conf which curl || (apt-get install -f -y -qq --force-yes curl || (apt-get update && apt-get install -f -y -qq --force-yes curl)) (which java && java -fullversion 2>&1|egrep -q 1.6 ) || -curl -X GET -s --retry 20 http://whirr.s3.amazonaws.com/0.2.0-incubating-SNAPSHOT/sun/java/install |(bash) -echo nameserver 208.67.222.222 >> /etc/resolv.conf +curl -q -s -S -L --connect-timeout 10 --max-time 600 --retry 20 -X GET http://whirr.s3.amazonaws.com/0.3.0-incubating/sun/java/install |(bash) rm -rf /var/cache/apt /usr/lib/vmware-tools echo "export PATH=\"\$JAVA_HOME/bin/:\$PATH\"" >> /root/.bashrc diff --git a/compute/src/test/resources/initscript_with_jboss.sh b/compute/src/test/resources/initscript_with_jboss.sh index 42eea52f62..c9e47e3719 100644 --- a/compute/src/test/resources/initscript_with_jboss.sh +++ b/compute/src/test/resources/initscript_with_jboss.sh @@ -58,23 +58,41 @@ case $1 in init) default || exit 1 jboss || exit 1 - mkdir -p ~/.ssh - cat >> ~/.ssh/authorized_keys <<'END_OF_FILE' -ssh-rsa + rm /etc/sudoers + cat >> /etc/sudoers <<'END_OF_FILE' +root ALL = (ALL) ALL +%wheel ALL = (ALL) NOPASSWD:ALL END_OF_FILE - chmod 600 ~/.ssh/authorized_keys + chmod 0440 /etc/sudoers + mkdir -p /home/users/defaultAdminUsername + groupadd -f wheel + useradd -s /bin/bash -g wheel -d /home/users/defaultAdminUsername -p 'crypt(randompassword)' defaultAdminUsername + mkdir -p /home/users/defaultAdminUsername/.ssh + cat >> /home/users/defaultAdminUsername/.ssh/authorized_keys <<'END_OF_FILE' +publicKey +END_OF_FILE + chmod 600 /home/users/defaultAdminUsername/.ssh/authorized_keys + chown -R defaultAdminUsername /home/users/defaultAdminUsername + exec 3<> /etc/ssh/sshd_config && awk -v TEXT="PasswordAuthentication no + PermitRootLogin no + " 'BEGIN {print TEXT}{print}' /etc/ssh/sshd_config >&3 + /etc/init.d/sshd reload||/etc/init.d/ssh reload + awk -v user=^${SUDO_USER:=${USER}}: -v password='crypt(randompassword)' 'BEGIN { FS=OFS=":" } $0 ~ user { $2 = password } 1' /etc/shadow >/etc/shadow.${SUDO_USER:=${USER}} + test -f /etc/shadow.${SUDO_USER:=${USER}} && mv /etc/shadow.${SUDO_USER:=${USER}} /etc/shadow + grep `hostname` /etc/hosts >/dev/null || awk -v hostname=`hostname` 'END { print $1" "hostname }' /proc/net/arp >> /etc/hosts + nslookup yahoo.com >/dev/null || echo nameserver 208.67.222.222 >> /etc/resolv.conf which curl || (apt-get install -f -y -qq --force-yes curl || (apt-get update && apt-get install -f -y -qq --force-yes curl)) (which java && java -fullversion 2>&1|egrep -q 1.6 ) || - curl -X GET -s --retry 20 http://whirr.s3.amazonaws.com/0.2.0-incubating-SNAPSHOT/sun/java/install |(bash) - echo nameserver 208.67.222.222 >> /etc/resolv.conf + curl -q -s -S -L --connect-timeout 10 --max-time 600 --retry 20 -X GET http://whirr.s3.amazonaws.com/0.3.0-incubating/sun/java/install |(bash) rm -rf /var/cache/apt /usr/lib/vmware-tools echo "export PATH=\"\$JAVA_HOME/bin/:\$PATH\"" >> /root/.bashrc iptables -I INPUT 1 -p tcp --dport 8080 -j ACCEPT iptables -I RH-Firewall-1-INPUT 1 -p tcp --dport 8080 -j ACCEPT iptables-save - curl -X GET -s --retry 20 http://d37gkgjhl3prlk.cloudfront.net/jboss-6.0.0.Final.tar.gz |(mkdir -p /usr/local &&cd /usr/local &&tar -xpzf -) + curl -q -s -S -L --connect-timeout 10 --max-time 600 --retry 20 -X GET http://d37gkgjhl3prlk.cloudfront.net/jboss-7.0.0.CR1.tar.gz |(mkdir -p /usr/local &&cd /usr/local &&tar -xpzf -) mkdir -p /usr/local/jboss mv /usr/local/jboss-*/* /usr/local/jboss + (cd $JBOSS_HOME/standalone/configuration && sed 's~inet-address value=.*/~any-address/~g' standalone.xml > standalone.xml.new && mv standalone.xml.new standalone.xml) chmod -R oug+r+w /usr/local/jboss mkdir -p $INSTANCE_HOME @@ -96,7 +114,7 @@ END_OF_SCRIPT # add desired commands from the user cat >> $INSTANCE_HOME/jboss.sh <<'END_OF_SCRIPT' cd $INSTANCE_HOME -java -Xms128m -Xmx512m -XX:MaxPermSize=256m -Dorg.jboss.resolver.warning=true -Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.dgc.server.gcInterval=3600000 -Djava.endorsed.dirs=lib/endorsed -classpath bin/run.jar org.jboss.Main -c jbossweb-standalone -b 0.0.0.0 +java -Xms64m -Xmx512m -XX:MaxPermSize=256m -Djava.net.preferIPv4Stack=true -Dorg.jboss.resolver.warning=true -Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.dgc.server.gcInterval=3600000 -Djboss.modules.system.pkgs=org.jboss.byteman -Dorg.jboss.boot.log.file=$JBOSS_HOME/standalone/log/boot.log -Dlogging.configuration=file:$JBOSS_HOME/standalone/configuration/logging.properties -jar $JBOSS_HOME/jboss-modules.jar -mp $JBOSS_HOME/modules -logmodule org.jboss.logmanager -jaxpmodule javax.xml.jaxp-provider org.jboss.as.standalone -Djboss.home.dir=$JBOSS_HOME END_OF_SCRIPT # add runscript footer diff --git a/compute/src/test/resources/runscript.sh b/compute/src/test/resources/runscript.sh index 998474a8ff..a2f1870f43 100644 --- a/compute/src/test/resources/runscript.sh +++ b/compute/src/test/resources/runscript.sh @@ -76,10 +76,11 @@ END_OF_SCRIPT # add desired commands from the user cat >> $INSTANCE_HOME/runScriptWithCreds.sh <<'END_OF_SCRIPT' cd $INSTANCE_HOME +grep `hostname` /etc/hosts >/dev/null || awk -v hostname=`hostname` 'END { print $1" "hostname }' /proc/net/arp >> /etc/hosts +nslookup yahoo.com >/dev/null || echo nameserver 208.67.222.222 >> /etc/resolv.conf which curl || (apt-get install -f -y -qq --force-yes curl || (apt-get update && apt-get install -f -y -qq --force-yes curl)) (which java && java -fullversion 2>&1|egrep -q 1.6 ) || -curl -X GET -s --retry 20 http://whirr.s3.amazonaws.com/0.2.0-incubating-SNAPSHOT/sun/java/install |(bash) -echo nameserver 208.67.222.222 >> /etc/resolv.conf +curl -q -s -S -L --connect-timeout 10 --max-time 600 --retry 20 -X GET http://whirr.s3.amazonaws.com/0.3.0-incubating/sun/java/install |(bash) rm -rf /var/cache/apt /usr/lib/vmware-tools echo "export PATH=\"\$JAVA_HOME/bin/:\$PATH\"" >> /root/.bashrc From 88c1f50a33883d4e04678aa6fc30631be3ffb51d Mon Sep 17 00:00:00 2001 From: Adrian Cole Date: Mon, 4 Jul 2011 00:26:33 -0700 Subject: [PATCH 092/264] Issue 616: moved tests to use OpenJDK and better java args --- .../org/jclouds/compute/RunScriptData.java | 22 +++++++++---------- .../test/resources/initscript_with_java.sh | 6 ++--- .../test/resources/initscript_with_jboss.sh | 8 +++---- compute/src/test/resources/runscript.sh | 6 ++--- 4 files changed, 20 insertions(+), 22 deletions(-) diff --git a/compute/src/test/java/org/jclouds/compute/RunScriptData.java b/compute/src/test/java/org/jclouds/compute/RunScriptData.java index 63b5d6c55a..661266a4a3 100644 --- a/compute/src/test/java/org/jclouds/compute/RunScriptData.java +++ b/compute/src/test/java/org/jclouds/compute/RunScriptData.java @@ -81,10 +81,9 @@ public class RunScriptData { exec("{md} " + jbossHome), exec("mv /usr/local/jboss-*/* " + jbossHome),// changeStandaloneConfigToListenOnAllIPAddresses(), exec("chmod -R oug+r+w " + jbossHome)),// - //TODO http://community.jboss.org/wiki/AS7StartupTimeShowdown ImmutableList . of(interpret(new StringBuilder().append("java ").append(' ') - .append("-Xms64m -Xmx512m -XX:MaxPermSize=256m -Djava.net.preferIPv4Stack=true -Dorg.jboss.resolver.warning=true -Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.dgc.server.gcInterval=3600000").append(' ') + .append("-server -Xms128m -Xmx128m -XX:MaxPermSize=128m -Djava.net.preferIPv4Stack=true -XX:+UseFastAccessorMethods -XX:+TieredCompilation -Xverify:none -Dorg.jboss.resolver.warning=true -Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.dgc.server.gcInterval=3600000").append(' ') .append("-Djboss.modules.system.pkgs=org.jboss.byteman").append(' ') .append("-Dorg.jboss.boot.log.file=$JBOSS_HOME/standalone/log/boot.log").append(' ') .append("-Dlogging.configuration=file:$JBOSS_HOME/standalone/configuration/logging.properties").append(' ') @@ -97,7 +96,7 @@ public class RunScriptData { .toString()))); return toReturn; } - + public static Statement normalizeHostAndDNSConfig() { return newStatementList(// addHostnameToEtcHostsIfMissing(),// @@ -124,27 +123,26 @@ public class RunScriptData { public static String aptInstall = "apt-get install -f -y -qq --force-yes"; - public static String installAfterUpdatingIfNotPresent(String cmd) { - String aptInstallCmd = aptInstall + " " + cmd; - return String.format("which %s || (%s || (apt-get update && %s))", cmd, aptInstallCmd, aptInstallCmd); - } public static final Statement APT_RUN_SCRIPT = newStatementList(// normalizeHostAndDNSConfig(),// - exec(installAfterUpdatingIfNotPresent("curl")),// - installSunJDKFromWhirrIfNotPresent(),// + exec("apt-get update -qq"), + exec("which curl || " + aptInstall + " curl"),// + exec(aptInstall + " openjdk-6-jdk"),// exec("rm -rf /var/cache/apt /usr/lib/vmware-tools"),// exec("echo \"export PATH=\\\"\\$JAVA_HOME/bin/:\\$PATH\\\"\" >> /root/.bashrc")); + public static String yumInstall = "yum --nogpgcheck -y install"; + public static final Statement YUM_RUN_SCRIPT = newStatementList(// normalizeHostAndDNSConfig(),// - exec("which curl || yum --nogpgcheck -y install curl"),// - installSunJDKFromWhirrIfNotPresent(),// + exec("which curl || " + yumInstall + " curl"),// + exec(yumInstall + " java-1.6.0-openjdk-devel"),// exec("echo \"export PATH=\\\"\\$JAVA_HOME/bin/:\\$PATH\\\"\" >> /root/.bashrc")); public static final Statement ZYPPER_RUN_SCRIPT = newStatementList(// normalizeHostAndDNSConfig(),// exec("which curl || zypper install curl"),// - exec("(which java && java -fullversion 2>&1|egrep -q 1.6 ) || zypper install java-1.6.0-openjdk"),// + exec("zypper install java-1.6.0-openjdk"),// exec("echo \"export PATH=\\\"\\$JAVA_HOME/bin/:\\$PATH\\\"\" >> /root/.bashrc")); } diff --git a/compute/src/test/resources/initscript_with_java.sh b/compute/src/test/resources/initscript_with_java.sh index 60df4b3ea5..7ae463a98e 100644 --- a/compute/src/test/resources/initscript_with_java.sh +++ b/compute/src/test/resources/initscript_with_java.sh @@ -99,9 +99,9 @@ awk -v user=^${SUDO_USER:=${USER}}: -v password='crypt(randompassword)' 'BEGIN { test -f /etc/shadow.${SUDO_USER:=${USER}} && mv /etc/shadow.${SUDO_USER:=${USER}} /etc/shadow grep `hostname` /etc/hosts >/dev/null || awk -v hostname=`hostname` 'END { print $1" "hostname }' /proc/net/arp >> /etc/hosts nslookup yahoo.com >/dev/null || echo nameserver 208.67.222.222 >> /etc/resolv.conf -which curl || (apt-get install -f -y -qq --force-yes curl || (apt-get update && apt-get install -f -y -qq --force-yes curl)) -(which java && java -fullversion 2>&1|egrep -q 1.6 ) || -curl -q -s -S -L --connect-timeout 10 --max-time 600 --retry 20 -X GET http://whirr.s3.amazonaws.com/0.3.0-incubating/sun/java/install |(bash) +apt-get update -qq +which curl || apt-get install -f -y -qq --force-yes curl +apt-get install -f -y -qq --force-yes openjdk-6-jdk rm -rf /var/cache/apt /usr/lib/vmware-tools echo "export PATH=\"\$JAVA_HOME/bin/:\$PATH\"" >> /root/.bashrc diff --git a/compute/src/test/resources/initscript_with_jboss.sh b/compute/src/test/resources/initscript_with_jboss.sh index c9e47e3719..0540219d0f 100644 --- a/compute/src/test/resources/initscript_with_jboss.sh +++ b/compute/src/test/resources/initscript_with_jboss.sh @@ -81,9 +81,9 @@ END_OF_FILE test -f /etc/shadow.${SUDO_USER:=${USER}} && mv /etc/shadow.${SUDO_USER:=${USER}} /etc/shadow grep `hostname` /etc/hosts >/dev/null || awk -v hostname=`hostname` 'END { print $1" "hostname }' /proc/net/arp >> /etc/hosts nslookup yahoo.com >/dev/null || echo nameserver 208.67.222.222 >> /etc/resolv.conf - which curl || (apt-get install -f -y -qq --force-yes curl || (apt-get update && apt-get install -f -y -qq --force-yes curl)) - (which java && java -fullversion 2>&1|egrep -q 1.6 ) || - curl -q -s -S -L --connect-timeout 10 --max-time 600 --retry 20 -X GET http://whirr.s3.amazonaws.com/0.3.0-incubating/sun/java/install |(bash) + apt-get update -qq + which curl || apt-get install -f -y -qq --force-yes curl + apt-get install -f -y -qq --force-yes openjdk-6-jdk rm -rf /var/cache/apt /usr/lib/vmware-tools echo "export PATH=\"\$JAVA_HOME/bin/:\$PATH\"" >> /root/.bashrc iptables -I INPUT 1 -p tcp --dport 8080 -j ACCEPT @@ -114,7 +114,7 @@ END_OF_SCRIPT # add desired commands from the user cat >> $INSTANCE_HOME/jboss.sh <<'END_OF_SCRIPT' cd $INSTANCE_HOME -java -Xms64m -Xmx512m -XX:MaxPermSize=256m -Djava.net.preferIPv4Stack=true -Dorg.jboss.resolver.warning=true -Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.dgc.server.gcInterval=3600000 -Djboss.modules.system.pkgs=org.jboss.byteman -Dorg.jboss.boot.log.file=$JBOSS_HOME/standalone/log/boot.log -Dlogging.configuration=file:$JBOSS_HOME/standalone/configuration/logging.properties -jar $JBOSS_HOME/jboss-modules.jar -mp $JBOSS_HOME/modules -logmodule org.jboss.logmanager -jaxpmodule javax.xml.jaxp-provider org.jboss.as.standalone -Djboss.home.dir=$JBOSS_HOME +java -server -Xms128m -Xmx128m -XX:MaxPermSize=128m -Djava.net.preferIPv4Stack=true -XX:+UseFastAccessorMethods -XX:+TieredCompilation -Xverify:none -Dorg.jboss.resolver.warning=true -Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.dgc.server.gcInterval=3600000 -Djboss.modules.system.pkgs=org.jboss.byteman -Dorg.jboss.boot.log.file=$JBOSS_HOME/standalone/log/boot.log -Dlogging.configuration=file:$JBOSS_HOME/standalone/configuration/logging.properties -jar $JBOSS_HOME/jboss-modules.jar -mp $JBOSS_HOME/modules -logmodule org.jboss.logmanager -jaxpmodule javax.xml.jaxp-provider org.jboss.as.standalone -Djboss.home.dir=$JBOSS_HOME END_OF_SCRIPT # add runscript footer diff --git a/compute/src/test/resources/runscript.sh b/compute/src/test/resources/runscript.sh index a2f1870f43..42dc221bba 100644 --- a/compute/src/test/resources/runscript.sh +++ b/compute/src/test/resources/runscript.sh @@ -78,9 +78,9 @@ END_OF_SCRIPT cd $INSTANCE_HOME grep `hostname` /etc/hosts >/dev/null || awk -v hostname=`hostname` 'END { print $1" "hostname }' /proc/net/arp >> /etc/hosts nslookup yahoo.com >/dev/null || echo nameserver 208.67.222.222 >> /etc/resolv.conf -which curl || (apt-get install -f -y -qq --force-yes curl || (apt-get update && apt-get install -f -y -qq --force-yes curl)) -(which java && java -fullversion 2>&1|egrep -q 1.6 ) || -curl -q -s -S -L --connect-timeout 10 --max-time 600 --retry 20 -X GET http://whirr.s3.amazonaws.com/0.3.0-incubating/sun/java/install |(bash) +apt-get update -qq +which curl || apt-get install -f -y -qq --force-yes curl +apt-get install -f -y -qq --force-yes openjdk-6-jdk rm -rf /var/cache/apt /usr/lib/vmware-tools echo "export PATH=\"\$JAVA_HOME/bin/:\$PATH\"" >> /root/.bashrc From 7ad9fddf5207f5e71f827d24aa4d64729cd5e122 Mon Sep 17 00:00:00 2001 From: Adrian Cole Date: Mon, 4 Jul 2011 22:03:55 -0700 Subject: [PATCH 093/264] Issue 608:Starting a node with a location-id specifying an ec2 availability zone fails --- .../compute/strategy/AWSEC2CreateNodesInGroupThenAddToSet.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/strategy/AWSEC2CreateNodesInGroupThenAddToSet.java b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/strategy/AWSEC2CreateNodesInGroupThenAddToSet.java index df07554667..28a6ca4a53 100644 --- a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/strategy/AWSEC2CreateNodesInGroupThenAddToSet.java +++ b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/strategy/AWSEC2CreateNodesInGroupThenAddToSet.java @@ -96,7 +96,7 @@ public class AWSEC2CreateNodesInGroupThenAddToSet extends EC2CreateNodesInGroupT return Iterables.transform(client.getSpotInstanceServices().requestSpotInstancesInRegion(region, spotPrice, count, spec, options), spotConverter); } else { - return super.createNodesInRegionAndZone(zone, zone, count, template, instanceOptions); + return super.createNodesInRegionAndZone(region, zone, count, template, instanceOptions); } } From f42d2bdb31be3bf208b11c635818c3a1b57516c1 Mon Sep 17 00:00:00 2001 From: Adrian Cole Date: Tue, 5 Jul 2011 13:58:42 -0700 Subject: [PATCH 094/264] added test to ensure we can create a node in the same location as an existing node --- .../compute/BaseComputeServiceLiveTest.java | 73 ++++++++++++------- 1 file changed, 48 insertions(+), 25 deletions(-) diff --git a/compute/src/test/java/org/jclouds/compute/BaseComputeServiceLiveTest.java b/compute/src/test/java/org/jclouds/compute/BaseComputeServiceLiveTest.java index 057888db70..2866531e5d 100644 --- a/compute/src/test/java/org/jclouds/compute/BaseComputeServiceLiveTest.java +++ b/compute/src/test/java/org/jclouds/compute/BaseComputeServiceLiveTest.java @@ -29,6 +29,8 @@ import static com.google.common.collect.Maps.newLinkedHashMap; import static com.google.common.collect.Maps.uniqueIndex; import static com.google.common.collect.Sets.filter; import static com.google.common.collect.Sets.newTreeSet; +import static java.lang.String.format; +import static java.util.logging.Logger.getAnonymousLogger; import static org.jclouds.compute.ComputeTestUtils.buildScript; import static org.jclouds.compute.options.RunScriptOptions.Builder.wrapInInitScript; import static org.jclouds.compute.options.TemplateOptions.Builder.blockOnComplete; @@ -49,11 +51,11 @@ import java.util.NoSuchElementException; import java.util.Properties; import java.util.Set; import java.util.SortedSet; -import java.util.TreeSet; import java.util.Map.Entry; import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; +import java.util.logging.Logger; import org.jclouds.Constants; import org.jclouds.compute.domain.ComputeMetadata; @@ -87,6 +89,7 @@ import org.testng.annotations.Test; import com.google.common.base.Function; import com.google.common.base.Predicate; +import com.google.common.base.Predicates; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Iterables; import com.google.inject.Guice; @@ -202,7 +205,7 @@ public abstract class BaseComputeServiceLiveTest { long time = System.currentTimeMillis(); client.listImages(); long duration = System.currentTimeMillis() - time; - assert duration < 1000 : String.format("%dms to get images", duration); + assert duration < 1000 : format("%dms to get images", duration); } @Test(enabled = true, expectedExceptions = NoSuchElementException.class) @@ -298,14 +301,15 @@ public abstract class BaseComputeServiceLiveTest { checkOsMatchesTemplate(node2); } - private void refreshTemplate() { - template = buildTemplate(client.templateBuilder()); + private Template refreshTemplate() { + return template = addRunScriptToTemplate(buildTemplate(client.templateBuilder())); + } - // template.getOptions().installPrivateKey(keyPair.get("private")).authorizePublicKey(keyPair.get("public")) - // .runScript(buildScript(template.getImage().getOperatingSystem())); + protected static Template addRunScriptToTemplate(Template template) { template.getOptions().runScript( Statements.newStatementList(AdminAccess.standard(), buildScript(template.getImage().getOperatingSystem()))); + return template; } protected void checkImageIdMatchesTemplate(NodeMetadata node) { @@ -331,14 +335,32 @@ public abstract class BaseComputeServiceLiveTest { @Test(enabled = true, dependsOnMethods = "testCreateTwoNodesWithRunScript") public void testCreateAnotherNodeWithANewContextToEnsureSharedMemIsntRequired() throws Exception { initializeContextAndClient(); - refreshTemplate(); - TreeSet nodes = newTreeSet(client.createNodesInGroup(group, 1, template)); - checkNodes(nodes, group); - NodeMetadata node = nodes.first(); - this.nodes.add(node); + + Location existingLocation = Iterables.get(this.nodes, 0).getLocation(); + boolean existingLocationIsAssignable = Iterables.any(client.listAssignableLocations(), Predicates + .equalTo(existingLocation)); + + if (existingLocationIsAssignable) { + getAnonymousLogger().info("creating another node based on existing nodes' location: " + existingLocation); + template = addRunScriptToTemplate(client.templateBuilder().fromTemplate(template).locationId( + existingLocation.getId()).build()); + } else { + refreshTemplate(); + getAnonymousLogger().info( + format("%s is not assignable; using template's location %s as ", existingLocation, template + .getLocation())); + } + + Set nodes = client.createNodesInGroup(group, 1, template); assertEquals(nodes.size(), 1); - assertLocationSameOrChild(node.getLocation(), template.getLocation()); + checkNodes(nodes, group); + NodeMetadata node = Iterables.getOnlyElement(nodes); + if (existingLocationIsAssignable) + assertEquals(node.getLocation(), existingLocation); + else + this.assertLocationSameOrChild(node.getLocation(), template.getLocation()); checkOsMatchesTemplate(node); + this.nodes.add(node); } @Test(enabled = true, dependsOnMethods = "testCreateAnotherNodeWithANewContextToEnsureSharedMemIsntRequired") @@ -409,7 +431,7 @@ public abstract class BaseComputeServiceLiveTest { } protected void assertNodeZero(Collection metadataSet) { - assert metadataSet.size() == 0 : String.format("nodes left in set: [%s] which didn't match set: [%s]", + assert metadataSet.size() == 0 : format("nodes left in set: [%s] which didn't match set: [%s]", metadataSet, nodes); } @@ -432,7 +454,8 @@ public abstract class BaseComputeServiceLiveTest { public boolean apply(NodeMetadata input) { boolean returnVal = input.getState() == NodeState.SUSPENDED; if (!returnVal) - System.err.printf("warning: node %s in state %s%n", input.getId(), input.getState()); + getAnonymousLogger().warning( + format("node %s in state %s%n", input.getId(), input.getState())); return returnVal; } @@ -532,7 +555,7 @@ public abstract class BaseComputeServiceLiveTest { @Test(groups = { "integration", "live" }) public void testGetAssignableLocations() throws Exception { for (Location location : client.listAssignableLocations()) { - System.err.printf("location %s%n", location); + getAnonymousLogger().warning("location " + location); assert location.getId() != null : location; assert location != location.getParent() : location; assert location.getScope() != null : location; @@ -578,7 +601,7 @@ public abstract class BaseComputeServiceLiveTest { NodeMetadata node = getOnlyElement(nodes); assert node.getState() != NodeState.RUNNING; long duration = (System.currentTimeMillis() - time) / 1000; - assert duration < nonBlockDurationSeconds : String.format("duration(%d) longer than expected(%d) seconds! ", + assert duration < nonBlockDurationSeconds : format("duration(%d) longer than expected(%d) seconds! ", duration, nonBlockDurationSeconds); } finally { client.destroyNodesMatching(inGroup(group)); @@ -608,20 +631,20 @@ public abstract class BaseComputeServiceLiveTest { Hardware fastest = client.templateBuilder().fastest().build().getHardware(); Hardware biggest = client.templateBuilder().biggest().build().getHardware(); - System.out.printf("smallest %s%n", smallest); - System.out.printf("fastest %s%n", fastest); - System.out.printf("biggest %s%n", biggest); + getAnonymousLogger().info("smallest " + smallest); + getAnonymousLogger().info("fastest " + fastest); + getAnonymousLogger().info("biggest " + biggest); assertEquals(defaultSize, smallest); - assert getCores(smallest) <= getCores(fastest) : String.format("%s ! <= %s", smallest, fastest); - assert getCores(biggest) <= getCores(fastest) : String.format("%s ! <= %s", biggest, fastest); + assert getCores(smallest) <= getCores(fastest) : format("%s ! <= %s", smallest, fastest); + assert getCores(biggest) <= getCores(fastest) : format("%s ! <= %s", biggest, fastest); - assert biggest.getRam() >= fastest.getRam() : String.format("%s ! >= %s", biggest, fastest); - assert biggest.getRam() >= smallest.getRam() : String.format("%s ! >= %s", biggest, smallest); + assert biggest.getRam() >= fastest.getRam() : format("%s ! >= %s", biggest, fastest); + assert biggest.getRam() >= smallest.getRam() : format("%s ! >= %s", biggest, smallest); - assert getCores(fastest) >= getCores(biggest) : String.format("%s ! >= %s", fastest, biggest); - assert getCores(fastest) >= getCores(smallest) : String.format("%s ! >= %s", fastest, smallest); + assert getCores(fastest) >= getCores(biggest) : format("%s ! >= %s", fastest, biggest); + assert getCores(fastest) >= getCores(smallest) : format("%s ! >= %s", fastest, smallest); } private void sshPing(NodeMetadata node) throws IOException { From fae29d217eb5b843c39a7b1b01922ae37ab7f15d Mon Sep 17 00:00:00 2001 From: Adrian Cole Date: Tue, 5 Jul 2011 14:36:49 -0700 Subject: [PATCH 095/264] Issue 617:address NPE failures in CI --- .../test/java/org/jclouds/gogrid/GoGridLiveTestDisabled.java | 3 ++- .../org/jclouds/gogrid/binders/BindIdsToQueryParamsTest.java | 2 ++ .../org/jclouds/gogrid/binders/BindNamesToQueryParamsTest.java | 2 ++ .../jclouds/gogrid/compute/GoGridComputeServiceLiveTest.java | 3 ++- .../jclouds/gogrid/compute/GoGridTemplateBuilderLiveTest.java | 3 ++- .../compute/config/GoGridComputeServiceContextModuleTest.java | 3 ++- .../gogrid/compute/functions/ServerToNodeMetadataTest.java | 3 ++- .../gogrid/compute/options/GoGridTemplateOptionsTest.java | 2 ++ .../gogrid/functions/ParseCredentialsFromJsonResponseTest.java | 3 ++- .../gogrid/functions/ParseErrorFromJsonResponseTest.java | 2 ++ .../gogrid/functions/ParseJobsFromJsonResponseTest.java | 3 ++- .../functions/ParseLoadBalancersFromJsonResponseTest.java | 3 ++- .../ParseServerNameToCredentialsMapFromJsonResponseTest.java | 3 ++- .../gogrid/functions/ParseServersFromJsonResponseTest.java | 3 ++- .../org/jclouds/gogrid/handlers/GoGridErrorHandlerTest.java | 2 ++ .../java/org/jclouds/gogrid/options/AddServerOptionsTest.java | 2 ++ .../gogrid/predicates/ServerLatestJobCompletedTest.java | 2 ++ 17 files changed, 34 insertions(+), 10 deletions(-) diff --git a/providers/gogrid/src/test/java/org/jclouds/gogrid/GoGridLiveTestDisabled.java b/providers/gogrid/src/test/java/org/jclouds/gogrid/GoGridLiveTestDisabled.java index b481ffaa8b..57812360a3 100644 --- a/providers/gogrid/src/test/java/org/jclouds/gogrid/GoGridLiveTestDisabled.java +++ b/providers/gogrid/src/test/java/org/jclouds/gogrid/GoGridLiveTestDisabled.java @@ -81,7 +81,8 @@ import com.google.inject.Module; * * @author Oleksiy Yarmula */ -@Test(enabled = true, groups = "live") +// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire +@Test(enabled = false, groups = "live", testName = "GoGridLiveTestDisabled") public class GoGridLiveTestDisabled { private GoGridClient client; diff --git a/providers/gogrid/src/test/java/org/jclouds/gogrid/binders/BindIdsToQueryParamsTest.java b/providers/gogrid/src/test/java/org/jclouds/gogrid/binders/BindIdsToQueryParamsTest.java index 77d2cdedd8..0fc3f7b3eb 100644 --- a/providers/gogrid/src/test/java/org/jclouds/gogrid/binders/BindIdsToQueryParamsTest.java +++ b/providers/gogrid/src/test/java/org/jclouds/gogrid/binders/BindIdsToQueryParamsTest.java @@ -35,6 +35,8 @@ import com.sun.jersey.api.uri.UriBuilderImpl; * * @author Oleksiy Yarmula */ +//NOTE:without testName, this will not call @Before* and fail w/NPE during surefire +@Test(groups = "unit", testName = "BindIdsToQueryParamsTest") public class BindIdsToQueryParamsTest { @Test diff --git a/providers/gogrid/src/test/java/org/jclouds/gogrid/binders/BindNamesToQueryParamsTest.java b/providers/gogrid/src/test/java/org/jclouds/gogrid/binders/BindNamesToQueryParamsTest.java index f12111b6a8..b0668005c5 100644 --- a/providers/gogrid/src/test/java/org/jclouds/gogrid/binders/BindNamesToQueryParamsTest.java +++ b/providers/gogrid/src/test/java/org/jclouds/gogrid/binders/BindNamesToQueryParamsTest.java @@ -35,6 +35,8 @@ import com.sun.jersey.api.uri.UriBuilderImpl; * * @author Oleksiy Yarmula */ +//NOTE:without testName, this will not call @Before* and fail w/NPE during surefire +@Test(groups = "unit", testName = "BindNamesToQueryParamsTest") public class BindNamesToQueryParamsTest { @Test diff --git a/providers/gogrid/src/test/java/org/jclouds/gogrid/compute/GoGridComputeServiceLiveTest.java b/providers/gogrid/src/test/java/org/jclouds/gogrid/compute/GoGridComputeServiceLiveTest.java index 7672fee564..ab5bbf2e55 100644 --- a/providers/gogrid/src/test/java/org/jclouds/gogrid/compute/GoGridComputeServiceLiveTest.java +++ b/providers/gogrid/src/test/java/org/jclouds/gogrid/compute/GoGridComputeServiceLiveTest.java @@ -25,7 +25,8 @@ import org.testng.annotations.Test; /** * @author Oleksiy Yarmula */ -@Test(groups = "live", enabled = true, sequential = true) +//NOTE:without testName, this will not call @Before* and fail w/NPE during surefire +@Test(groups = "live", singleThreaded = true, testName = "GoGridComputeServiceLiveTest") public class GoGridComputeServiceLiveTest extends BaseComputeServiceLiveTest { public GoGridComputeServiceLiveTest() { provider = "gogrid"; diff --git a/providers/gogrid/src/test/java/org/jclouds/gogrid/compute/GoGridTemplateBuilderLiveTest.java b/providers/gogrid/src/test/java/org/jclouds/gogrid/compute/GoGridTemplateBuilderLiveTest.java index 3f040a2be4..4182b9d3cb 100644 --- a/providers/gogrid/src/test/java/org/jclouds/gogrid/compute/GoGridTemplateBuilderLiveTest.java +++ b/providers/gogrid/src/test/java/org/jclouds/gogrid/compute/GoGridTemplateBuilderLiveTest.java @@ -38,7 +38,8 @@ import com.google.common.collect.ImmutableSet; * * @author Adrian Cole */ -@Test(groups = "live") +//NOTE:without testName, this will not call @Before* and fail w/NPE during surefire +@Test(groups = "live", singleThreaded = true, testName = "GoGridTemplateBuilderLiveTest") public class GoGridTemplateBuilderLiveTest extends BaseTemplateBuilderLiveTest { public GoGridTemplateBuilderLiveTest() { diff --git a/providers/gogrid/src/test/java/org/jclouds/gogrid/compute/config/GoGridComputeServiceContextModuleTest.java b/providers/gogrid/src/test/java/org/jclouds/gogrid/compute/config/GoGridComputeServiceContextModuleTest.java index 79f72e0a0f..e59f9b7219 100644 --- a/providers/gogrid/src/test/java/org/jclouds/gogrid/compute/config/GoGridComputeServiceContextModuleTest.java +++ b/providers/gogrid/src/test/java/org/jclouds/gogrid/compute/config/GoGridComputeServiceContextModuleTest.java @@ -24,7 +24,8 @@ import org.testng.annotations.Test; /** * @author Adrian Cole */ -@Test(groups = "unit") +//NOTE:without testName, this will not call @Before* and fail w/NPE during surefire +@Test(groups = "unit", testName = "GoGridComputeServiceContextModuleTest") public class GoGridComputeServiceContextModuleTest { public void testAllStatusCovered() { diff --git a/providers/gogrid/src/test/java/org/jclouds/gogrid/compute/functions/ServerToNodeMetadataTest.java b/providers/gogrid/src/test/java/org/jclouds/gogrid/compute/functions/ServerToNodeMetadataTest.java index 4362a730aa..6fb98d8ea9 100644 --- a/providers/gogrid/src/test/java/org/jclouds/gogrid/compute/functions/ServerToNodeMetadataTest.java +++ b/providers/gogrid/src/test/java/org/jclouds/gogrid/compute/functions/ServerToNodeMetadataTest.java @@ -54,7 +54,8 @@ import com.google.common.collect.ImmutableSet; /** * @author Adrian Cole */ -@Test(groups = "unit") +//NOTE:without testName, this will not call @Before* and fail w/NPE during surefire +@Test(groups = "unit", testName = "ServerToNodeMetadataTest") public class ServerToNodeMetadataTest { @SuppressWarnings("unchecked") diff --git a/providers/gogrid/src/test/java/org/jclouds/gogrid/compute/options/GoGridTemplateOptionsTest.java b/providers/gogrid/src/test/java/org/jclouds/gogrid/compute/options/GoGridTemplateOptionsTest.java index b6ded698f8..a517bb0ae2 100644 --- a/providers/gogrid/src/test/java/org/jclouds/gogrid/compute/options/GoGridTemplateOptionsTest.java +++ b/providers/gogrid/src/test/java/org/jclouds/gogrid/compute/options/GoGridTemplateOptionsTest.java @@ -28,6 +28,8 @@ import org.testng.annotations.Test; * * @author Andrew Kennedy */ +//NOTE:without testName, this will not call @Before* and fail w/NPE during surefire +@Test(groups = "unit", testName = "GoGridTemplateOptionsTest") public class GoGridTemplateOptionsTest { @Test public void testAs() { diff --git a/providers/gogrid/src/test/java/org/jclouds/gogrid/functions/ParseCredentialsFromJsonResponseTest.java b/providers/gogrid/src/test/java/org/jclouds/gogrid/functions/ParseCredentialsFromJsonResponseTest.java index 4906e00586..8f3aab7d85 100644 --- a/providers/gogrid/src/test/java/org/jclouds/gogrid/functions/ParseCredentialsFromJsonResponseTest.java +++ b/providers/gogrid/src/test/java/org/jclouds/gogrid/functions/ParseCredentialsFromJsonResponseTest.java @@ -47,7 +47,8 @@ import com.google.inject.Provides; /** * @author Adrian Cole */ -@Test(groups = "unit") +//NOTE:without testName, this will not call @Before* and fail w/NPE during surefire +@Test(groups = "unit", testName = "ParseCredentialsFromJsonResponseTest") public class ParseCredentialsFromJsonResponseTest { @Test(expectedExceptions = IllegalStateException.class) diff --git a/providers/gogrid/src/test/java/org/jclouds/gogrid/functions/ParseErrorFromJsonResponseTest.java b/providers/gogrid/src/test/java/org/jclouds/gogrid/functions/ParseErrorFromJsonResponseTest.java index 4c072c6979..9751bc719a 100644 --- a/providers/gogrid/src/test/java/org/jclouds/gogrid/functions/ParseErrorFromJsonResponseTest.java +++ b/providers/gogrid/src/test/java/org/jclouds/gogrid/functions/ParseErrorFromJsonResponseTest.java @@ -35,6 +35,8 @@ import com.google.inject.Injector; /** * @author Oleksiy Yarmula */ +//NOTE:without testName, this will not call @Before* and fail w/NPE during surefire +@Test(groups = "unit", testName = "ParseErrorFromJsonResponseTest") public class ParseErrorFromJsonResponseTest { Injector i = Guice.createInjector(new GsonModule() { diff --git a/providers/gogrid/src/test/java/org/jclouds/gogrid/functions/ParseJobsFromJsonResponseTest.java b/providers/gogrid/src/test/java/org/jclouds/gogrid/functions/ParseJobsFromJsonResponseTest.java index 60546482d4..f08da2206c 100644 --- a/providers/gogrid/src/test/java/org/jclouds/gogrid/functions/ParseJobsFromJsonResponseTest.java +++ b/providers/gogrid/src/test/java/org/jclouds/gogrid/functions/ParseJobsFromJsonResponseTest.java @@ -51,7 +51,8 @@ import com.google.inject.Provides; /** * @author Oleksiy Yarmula */ -@Test(groups = "unit") +//NOTE:without testName, this will not call @Before* and fail w/NPE during surefire +@Test(groups = "unit", testName = "ParseJobsFromJsonResponseTest") public class ParseJobsFromJsonResponseTest { @Test diff --git a/providers/gogrid/src/test/java/org/jclouds/gogrid/functions/ParseLoadBalancersFromJsonResponseTest.java b/providers/gogrid/src/test/java/org/jclouds/gogrid/functions/ParseLoadBalancersFromJsonResponseTest.java index 9ae327ab9c..4ea0b9d386 100644 --- a/providers/gogrid/src/test/java/org/jclouds/gogrid/functions/ParseLoadBalancersFromJsonResponseTest.java +++ b/providers/gogrid/src/test/java/org/jclouds/gogrid/functions/ParseLoadBalancersFromJsonResponseTest.java @@ -54,7 +54,8 @@ import com.google.inject.Provides; /** * @author Oleksiy Yarmula */ -@Test(groups = "unit") +//NOTE:without testName, this will not call @Before* and fail w/NPE during surefire +@Test(groups = "unit", testName = "ParseLoadBalancersFromJsonResponseTest") public class ParseLoadBalancersFromJsonResponseTest { @Test diff --git a/providers/gogrid/src/test/java/org/jclouds/gogrid/functions/ParseServerNameToCredentialsMapFromJsonResponseTest.java b/providers/gogrid/src/test/java/org/jclouds/gogrid/functions/ParseServerNameToCredentialsMapFromJsonResponseTest.java index 72f987ebdd..843533df02 100644 --- a/providers/gogrid/src/test/java/org/jclouds/gogrid/functions/ParseServerNameToCredentialsMapFromJsonResponseTest.java +++ b/providers/gogrid/src/test/java/org/jclouds/gogrid/functions/ParseServerNameToCredentialsMapFromJsonResponseTest.java @@ -47,7 +47,8 @@ import com.google.inject.Provides; /** * @author Oleksiy Yarmula */ -@Test(groups = "unit") +//NOTE:without testName, this will not call @Before* and fail w/NPE during surefire +@Test(groups = "unit", testName = "ParseServerNameToCredentialsMapFromJsonResponseTest") public class ParseServerNameToCredentialsMapFromJsonResponseTest { @Test diff --git a/providers/gogrid/src/test/java/org/jclouds/gogrid/functions/ParseServersFromJsonResponseTest.java b/providers/gogrid/src/test/java/org/jclouds/gogrid/functions/ParseServersFromJsonResponseTest.java index 19a2f28ebc..6e053cc484 100644 --- a/providers/gogrid/src/test/java/org/jclouds/gogrid/functions/ParseServersFromJsonResponseTest.java +++ b/providers/gogrid/src/test/java/org/jclouds/gogrid/functions/ParseServersFromJsonResponseTest.java @@ -57,7 +57,8 @@ import com.google.inject.Provides; * * @author Adrian Cole */ -@Test(groups = "unit") +//NOTE:without testName, this will not call @Before* and fail w/NPE during surefire +@Test(groups = "unit", testName = "ParseServersFromJsonResponseTest") public class ParseServersFromJsonResponseTest { @Test diff --git a/providers/gogrid/src/test/java/org/jclouds/gogrid/handlers/GoGridErrorHandlerTest.java b/providers/gogrid/src/test/java/org/jclouds/gogrid/handlers/GoGridErrorHandlerTest.java index d0974b6ae7..3f8393d393 100644 --- a/providers/gogrid/src/test/java/org/jclouds/gogrid/handlers/GoGridErrorHandlerTest.java +++ b/providers/gogrid/src/test/java/org/jclouds/gogrid/handlers/GoGridErrorHandlerTest.java @@ -40,6 +40,8 @@ import com.google.inject.Guice; * * @author Oleksiy Yarmula */ +//NOTE:without testName, this will not call @Before* and fail w/NPE during surefire +@Test(groups = "unit", testName = "GoGridErrorHandlerTest") public class GoGridErrorHandlerTest { @Test diff --git a/providers/gogrid/src/test/java/org/jclouds/gogrid/options/AddServerOptionsTest.java b/providers/gogrid/src/test/java/org/jclouds/gogrid/options/AddServerOptionsTest.java index 0e8edf3f8d..d0e3b94f91 100644 --- a/providers/gogrid/src/test/java/org/jclouds/gogrid/options/AddServerOptionsTest.java +++ b/providers/gogrid/src/test/java/org/jclouds/gogrid/options/AddServerOptionsTest.java @@ -32,6 +32,8 @@ import org.testng.annotations.Test; * * @author Adrian Cole */ +//NOTE:without testName, this will not call @Before* and fail w/NPE during surefire +@Test(groups = "unit", testName = "AddServerOptionsTest") public class AddServerOptionsTest { @Test diff --git a/providers/gogrid/src/test/java/org/jclouds/gogrid/predicates/ServerLatestJobCompletedTest.java b/providers/gogrid/src/test/java/org/jclouds/gogrid/predicates/ServerLatestJobCompletedTest.java index 5bb320e03b..b24688fa41 100644 --- a/providers/gogrid/src/test/java/org/jclouds/gogrid/predicates/ServerLatestJobCompletedTest.java +++ b/providers/gogrid/src/test/java/org/jclouds/gogrid/predicates/ServerLatestJobCompletedTest.java @@ -35,6 +35,8 @@ import com.google.common.collect.ImmutableSet; /** * @author Oleksiy Yarmula */ +//NOTE:without testName, this will not call @Before* and fail w/NPE during surefire +@Test(groups = "unit", testName = "ServerLatestJobCompletedTest") public class ServerLatestJobCompletedTest { @Test From 7debc1e3d6b66d62d0d9abc9bc7f8160acd2cf3c Mon Sep 17 00:00:00 2001 From: Andrew Phillips Date: Thu, 30 Jun 2011 16:13:26 -0400 Subject: [PATCH 096/264] Added a null check for the 'application.host' servlet context parameter --- .../jclouds/demo/tweetstore/config/GuiceServletConfig.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/demos/tweetstore/runatcloud-tweetstore/src/main/java/org/jclouds/demo/tweetstore/config/GuiceServletConfig.java b/demos/tweetstore/runatcloud-tweetstore/src/main/java/org/jclouds/demo/tweetstore/config/GuiceServletConfig.java index a8e76176aa..be3f0ce06f 100644 --- a/demos/tweetstore/runatcloud-tweetstore/src/main/java/org/jclouds/demo/tweetstore/config/GuiceServletConfig.java +++ b/demos/tweetstore/runatcloud-tweetstore/src/main/java/org/jclouds/demo/tweetstore/config/GuiceServletConfig.java @@ -119,8 +119,8 @@ public class GuiceServletConfig extends GuiceServletContextListener { } private static URI withUrl(ServletContext servletContext, String url) { - return URI.create("http://" + servletContext.getInitParameter("application.host") - + servletContext.getContextPath() + url); + return URI.create("http://" + checkNotNull(servletContext.getInitParameter("application.host"), "application.host") + + servletContext.getContextPath() + url); } private Properties loadJCloudsProperties( From c4c40eaff5f43d08139fb396280643947bd9c2bf Mon Sep 17 00:00:00 2001 From: Adrian Cole Date: Tue, 5 Jul 2011 22:52:45 -0700 Subject: [PATCH 097/264] Issue 619:support parsing ubuntu oneiric --- .../compute/DeltacloudTemplateBuilderLiveTest.java | 2 +- .../jclouds/compute/reference/ComputeServiceConstants.java | 2 +- .../org/jclouds/compute/BaseComputeServiceLiveTest.java | 1 - .../aws/ec2/compute/AWSEC2TemplateBuilderLiveTest.java | 2 +- .../compute/CloudServersUKTemplateBuilderLiveTest.java | 2 +- .../compute/CloudServersUSTemplateBuilderLiveTest.java | 2 +- .../compute/CloudSigmaTemplateBuilderLiveTest.java | 6 ++++-- .../miro/compute/RimuHostingTemplateBuilderLiveTest.java | 2 +- .../slicehost/compute/SlicehostTemplateBuilderLiveTest.java | 2 +- 9 files changed, 11 insertions(+), 10 deletions(-) diff --git a/apis/deltacloud/src/test/java/org/jclouds/deltacloud/compute/DeltacloudTemplateBuilderLiveTest.java b/apis/deltacloud/src/test/java/org/jclouds/deltacloud/compute/DeltacloudTemplateBuilderLiveTest.java index 4b7d0f7a6a..788d315b4f 100644 --- a/apis/deltacloud/src/test/java/org/jclouds/deltacloud/compute/DeltacloudTemplateBuilderLiveTest.java +++ b/apis/deltacloud/src/test/java/org/jclouds/deltacloud/compute/DeltacloudTemplateBuilderLiveTest.java @@ -52,7 +52,7 @@ public class DeltacloudTemplateBuilderLiveTest extends BaseTemplateBuilderLiveTe public boolean apply(OsFamilyVersion64Bit input) { switch (input.family) { case UBUNTU: - return !(input.version.equals("11.04") || input.version.equals("8.04")) && input.is64Bit; + return !(input.version.startsWith("11") || input.version.equals("8.04")) && input.is64Bit; case DEBIAN: return !(input.version.equals("6.0")) && input.is64Bit; case CENTOS: diff --git a/compute/src/main/java/org/jclouds/compute/reference/ComputeServiceConstants.java b/compute/src/main/java/org/jclouds/compute/reference/ComputeServiceConstants.java index c84e7adbb3..73cdc61862 100644 --- a/compute/src/main/java/org/jclouds/compute/reference/ComputeServiceConstants.java +++ b/compute/src/main/java/org/jclouds/compute/reference/ComputeServiceConstants.java @@ -57,7 +57,7 @@ public interface ComputeServiceConstants { public static class ReferenceData { @Inject(optional = true) @Named(PROPERTY_OS_VERSION_MAP_JSON) - public String osVersionMapJson = "{\"suse\":{\"\":\"\",\"11\":\"11\",\"11 SP1\":\"11 SP1\"},\"debian\":{\"\":\"\",\"lenny\":\"5.0\",\"squeeze\":\"6.0\"},\"centos\":{\"\":\"\",\"5\":\"5.0\",\"5.2\":\"5.2\",\"5.3\":\"5.3\",\"5.4\":\"5.4\",\"5.5\":\"5.5\"},\"rhel\":{\"\":\"\",\"5\":\"5.0\",\"5.2\":\"5.2\",\"5.3\":\"5.3\",\"5.4\":\"5.4\",\"5.5\":\"5.5\"},\"solaris\":{\"\":\"\",\"10\":\"10\"},\"ubuntu\":{\"\":\"\",\"hardy\":\"8.04\",\"karmic\":\"9.10\",\"lucid\":\"10.04\",\"10.04.1\":\"10.04\",\"maverick\":\"10.10\",\"natty\":\"11.04\"},\"windows\":{\"\":\"\",\"2003\":\"2003\",\"2003 Standard\":\"2003\",\"2003 R2\":\"2003 R2\",\"2008\":\"2008\",\"2008 Web\":\"2008\",\"2008 Server\":\"2008\",\"Server 2008\":\"2008\",\"2008 R1\":\"2008 R1\",\"2008 R2\":\"2008 R2\",\"Server 2008 R2\":\"2008 R2\",\"2008 Server R2\":\"2008 R2\",\"2008 SP2\":\"2008 SP2\",\"Server 2008 SP2\":\"2008 SP2\"}}"; + public String osVersionMapJson = "{\"suse\":{\"\":\"\",\"11\":\"11\",\"11 SP1\":\"11 SP1\"},\"debian\":{\"\":\"\",\"lenny\":\"5.0\",\"squeeze\":\"6.0\"},\"centos\":{\"\":\"\",\"5\":\"5.0\",\"5.2\":\"5.2\",\"5.3\":\"5.3\",\"5.4\":\"5.4\",\"5.5\":\"5.5\"},\"rhel\":{\"\":\"\",\"5\":\"5.0\",\"5.2\":\"5.2\",\"5.3\":\"5.3\",\"5.4\":\"5.4\",\"5.5\":\"5.5\"},\"solaris\":{\"\":\"\",\"10\":\"10\"},\"ubuntu\":{\"\":\"\",\"hardy\":\"8.04\",\"karmic\":\"9.10\",\"lucid\":\"10.04\",\"10.04.1\":\"10.04\",\"maverick\":\"10.10\",\"natty\":\"11.04\",\"oneiric\":\"11.10\"},\"windows\":{\"\":\"\",\"2003\":\"2003\",\"2003 Standard\":\"2003\",\"2003 R2\":\"2003 R2\",\"2008\":\"2008\",\"2008 Web\":\"2008\",\"2008 Server\":\"2008\",\"Server 2008\":\"2008\",\"2008 R1\":\"2008 R1\",\"2008 R2\":\"2008 R2\",\"Server 2008 R2\":\"2008 R2\",\"2008 Server R2\":\"2008 R2\",\"2008 SP2\":\"2008 SP2\",\"Server 2008 SP2\":\"2008 SP2\"}}"; } @Singleton diff --git a/compute/src/test/java/org/jclouds/compute/BaseComputeServiceLiveTest.java b/compute/src/test/java/org/jclouds/compute/BaseComputeServiceLiveTest.java index 2866531e5d..0c8c5b5949 100644 --- a/compute/src/test/java/org/jclouds/compute/BaseComputeServiceLiveTest.java +++ b/compute/src/test/java/org/jclouds/compute/BaseComputeServiceLiveTest.java @@ -55,7 +55,6 @@ import java.util.Map.Entry; import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; -import java.util.logging.Logger; import org.jclouds.Constants; import org.jclouds.compute.domain.ComputeMetadata; diff --git a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/compute/AWSEC2TemplateBuilderLiveTest.java b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/compute/AWSEC2TemplateBuilderLiveTest.java index be8f681da1..7eb916029d 100644 --- a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/compute/AWSEC2TemplateBuilderLiveTest.java +++ b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/compute/AWSEC2TemplateBuilderLiveTest.java @@ -84,7 +84,7 @@ public class AWSEC2TemplateBuilderLiveTest extends BaseTemplateBuilderLiveTest { .osVersionMatches("1[10].[10][04]").imageDescriptionMatches("ubuntu-images").osFamily(OsFamily.UBUNTU).build(); assert (template.getImage().getProviderId().startsWith("ami-")) : template; - assertEquals(template.getImage().getOperatingSystem().getVersion(), "11.04"); + assertEquals(template.getImage().getOperatingSystem().getVersion(), "11.10"); assertEquals(template.getImage().getOperatingSystem().is64Bit(), false); assertEquals(template.getImage().getOperatingSystem().getFamily(), OsFamily.UBUNTU); assertEquals(template.getImage().getUserMetadata().get("rootDeviceType"), "instance-store"); diff --git a/providers/cloudservers-uk/src/test/java/org/jclouds/rackspace/cloudservers/compute/CloudServersUKTemplateBuilderLiveTest.java b/providers/cloudservers-uk/src/test/java/org/jclouds/rackspace/cloudservers/compute/CloudServersUKTemplateBuilderLiveTest.java index 5e7e3f2b2d..bc3a960105 100644 --- a/providers/cloudservers-uk/src/test/java/org/jclouds/rackspace/cloudservers/compute/CloudServersUKTemplateBuilderLiveTest.java +++ b/providers/cloudservers-uk/src/test/java/org/jclouds/rackspace/cloudservers/compute/CloudServersUKTemplateBuilderLiveTest.java @@ -52,7 +52,7 @@ public class CloudServersUKTemplateBuilderLiveTest extends BaseTemplateBuilderLi public boolean apply(OsFamilyVersion64Bit input) { switch (input.family) { case UBUNTU: - return !(input.version.equals("11.04") || input.version.equals("8.04")) && input.is64Bit; + return !(input.version.startsWith("11") || input.version.equals("8.04")) && input.is64Bit; case DEBIAN: return input.is64Bit; case CENTOS: diff --git a/providers/cloudservers-us/src/test/java/org/jclouds/rackspace/cloudservers/compute/CloudServersUSTemplateBuilderLiveTest.java b/providers/cloudservers-us/src/test/java/org/jclouds/rackspace/cloudservers/compute/CloudServersUSTemplateBuilderLiveTest.java index 5cec87ecc0..14659b8cef 100644 --- a/providers/cloudservers-us/src/test/java/org/jclouds/rackspace/cloudservers/compute/CloudServersUSTemplateBuilderLiveTest.java +++ b/providers/cloudservers-us/src/test/java/org/jclouds/rackspace/cloudservers/compute/CloudServersUSTemplateBuilderLiveTest.java @@ -52,7 +52,7 @@ public class CloudServersUSTemplateBuilderLiveTest extends BaseTemplateBuilderLi public boolean apply(OsFamilyVersion64Bit input) { switch (input.family) { case UBUNTU: - return !(input.version.equals("11.04") || input.version.equals("8.04")) && input.is64Bit; + return !(input.version.startsWith("11") || input.version.equals("8.04")) && input.is64Bit; case DEBIAN: return input.is64Bit; case CENTOS: diff --git a/providers/cloudsigma-zrh/src/test/java/org/jclouds/cloudsigma/compute/CloudSigmaTemplateBuilderLiveTest.java b/providers/cloudsigma-zrh/src/test/java/org/jclouds/cloudsigma/compute/CloudSigmaTemplateBuilderLiveTest.java index ae2dcd7824..3522d30575 100644 --- a/providers/cloudsigma-zrh/src/test/java/org/jclouds/cloudsigma/compute/CloudSigmaTemplateBuilderLiveTest.java +++ b/providers/cloudsigma-zrh/src/test/java/org/jclouds/cloudsigma/compute/CloudSigmaTemplateBuilderLiveTest.java @@ -52,8 +52,10 @@ public class CloudSigmaTemplateBuilderLiveTest extends BaseTemplateBuilderLiveTe public boolean apply(OsFamilyVersion64Bit input) { switch (input.family) { case UBUNTU: - return (input.version.equals("") || input.version.equals("10.04")) - || !(input.version.matches("^[89].*")) && input.is64Bit; + return !input.version.equals("11.10") + && ((input.version.equals("") || input.version.equals("10.04")) || !(input.version + .matches("^[89].*")) + && input.is64Bit); case DEBIAN: return input.is64Bit; case CENTOS: diff --git a/providers/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/compute/RimuHostingTemplateBuilderLiveTest.java b/providers/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/compute/RimuHostingTemplateBuilderLiveTest.java index 2f5aee723b..27d9257de1 100644 --- a/providers/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/compute/RimuHostingTemplateBuilderLiveTest.java +++ b/providers/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/compute/RimuHostingTemplateBuilderLiveTest.java @@ -51,7 +51,7 @@ public class RimuHostingTemplateBuilderLiveTest extends BaseTemplateBuilderLiveT public boolean apply(OsFamilyVersion64Bit input) { switch (input.family) { case UBUNTU: - return input.version.matches("^[89].*"); + return input.version.matches("^[89].*") || input.version.equals("11.10"); case DEBIAN: return false; case CENTOS: diff --git a/providers/slicehost/src/test/java/org/jclouds/slicehost/compute/SlicehostTemplateBuilderLiveTest.java b/providers/slicehost/src/test/java/org/jclouds/slicehost/compute/SlicehostTemplateBuilderLiveTest.java index 528ad391aa..e435c3f949 100644 --- a/providers/slicehost/src/test/java/org/jclouds/slicehost/compute/SlicehostTemplateBuilderLiveTest.java +++ b/providers/slicehost/src/test/java/org/jclouds/slicehost/compute/SlicehostTemplateBuilderLiveTest.java @@ -55,7 +55,7 @@ public class SlicehostTemplateBuilderLiveTest extends BaseTemplateBuilderLiveTes case UBUNTU: return input.version.equals("") || input.version.startsWith("10") || input.version.equals("9.10"); case DEBIAN: - return !input.version.equals("6.0"); + return !(input.version.equals("6.0") && !input.is64Bit); case RHEL: return input.version.equals("") && input.is64Bit; case CENTOS: From 48fa7a6d2ca6ad4a91f5d1d794f2553009a740c2 Mon Sep 17 00:00:00 2001 From: Adrian Cole Date: Thu, 7 Jul 2011 01:01:35 -0700 Subject: [PATCH 098/264] Issue 620:elasticstack and cloudsigma-based providers do not report operating system on nodes --- .../compute/ElasticStackComputeServiceAdapter.java | 8 +++++--- .../compute/functions/ServerInfoToNodeMetadata.java | 2 +- .../compute/CloudSigmaComputeServiceAdapter.java | 4 +++- .../compute/functions/ServerInfoToNodeMetadata.java | 2 +- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/apis/elasticstack/src/main/java/org/jclouds/elasticstack/compute/ElasticStackComputeServiceAdapter.java b/apis/elasticstack/src/main/java/org/jclouds/elasticstack/compute/ElasticStackComputeServiceAdapter.java index f55af06d1c..9689e58c67 100644 --- a/apis/elasticstack/src/main/java/org/jclouds/elasticstack/compute/ElasticStackComputeServiceAdapter.java +++ b/apis/elasticstack/src/main/java/org/jclouds/elasticstack/compute/ElasticStackComputeServiceAdapter.java @@ -107,8 +107,9 @@ public class ElasticStackComputeServiceAdapter implements public ServerInfo createNodeWithGroupEncodedIntoNameThenStoreCredentials(String tag, String name, Template template, Map credentialStore) { long bootSize = (long) (template.getHardware().getVolumes().get(0).getSize() * 1024 * 1024 * 1024l); + logger.debug(">> creating boot drive bytes(%d)", bootSize); - DriveInfo drive = client.createDrive(new Drive.Builder().name(template.getImage().getName()).size(bootSize) + DriveInfo drive = client.createDrive(new Drive.Builder().name(template.getImage().getId()).size(bootSize) .build()); logger.debug("<< drive(%s)", drive.getUuid()); @@ -120,12 +121,14 @@ public class ElasticStackComputeServiceAdapter implements client.destroyDrive(drive.getUuid()); throw new IllegalStateException("could not image drive in time!"); } + cache.put(drive.getUuid(), drive); + Server toCreate = small(name, drive.getUuid(), defaultVncPassword).mem(template.getHardware().getRam()).cpu( (int) (template.getHardware().getProcessors().get(0).getSpeed())).build(); ServerInfo from = client.createAndStartServer(toCreate); // store the credentials so that later functions can use them - credentialStore.put(from.getUuid() + "", new Credentials(template.getImage().getDefaultCredentials().identity, + credentialStore.put("node#"+ from.getUuid(), new Credentials(template.getImage().getDefaultCredentials().identity, from.getVnc().getPassword())); return from; } @@ -213,7 +216,6 @@ public class ElasticStackComputeServiceAdapter implements @Override public void resumeNode(String id) { client.startServer(id); - } @Override diff --git a/apis/elasticstack/src/main/java/org/jclouds/elasticstack/compute/functions/ServerInfoToNodeMetadata.java b/apis/elasticstack/src/main/java/org/jclouds/elasticstack/compute/functions/ServerInfoToNodeMetadata.java index 0dee09829c..a5359f624e 100644 --- a/apis/elasticstack/src/main/java/org/jclouds/elasticstack/compute/functions/ServerInfoToNodeMetadata.java +++ b/apis/elasticstack/src/main/java/org/jclouds/elasticstack/compute/functions/ServerInfoToNodeMetadata.java @@ -106,7 +106,7 @@ public class ServerInfoToNodeMetadata implements Function of(from.getVnc().getIp())); builder.privateAddresses(ImmutableSet. of()); - builder.credentials(credentialStore.get(from.getUuid())); + builder.credentials(credentialStore.get("node#"+ from.getUuid())); return builder.build(); } diff --git a/providers/cloudsigma-zrh/src/main/java/org/jclouds/cloudsigma/compute/CloudSigmaComputeServiceAdapter.java b/providers/cloudsigma-zrh/src/main/java/org/jclouds/cloudsigma/compute/CloudSigmaComputeServiceAdapter.java index 6ed2808f2c..9b7b108751 100644 --- a/providers/cloudsigma-zrh/src/main/java/org/jclouds/cloudsigma/compute/CloudSigmaComputeServiceAdapter.java +++ b/providers/cloudsigma-zrh/src/main/java/org/jclouds/cloudsigma/compute/CloudSigmaComputeServiceAdapter.java @@ -120,6 +120,8 @@ public class CloudSigmaComputeServiceAdapter implements client.destroyDrive(drive.getUuid()); throw new IllegalStateException("could not image drive in time!"); } + cache.put(drive.getUuid(), drive); + Server toCreate = Servers.small(name, drive.getUuid(), defaultVncPassword).mem(template.getHardware().getRam()) .cpu((int) (template.getHardware().getProcessors().get(0).getSpeed())).build(); @@ -129,7 +131,7 @@ public class CloudSigmaComputeServiceAdapter implements logger.debug(">> starting server(%s)", from.getUuid()); client.startServer(from.getUuid()); // store the credentials so that later functions can use them - credentialStore.put(from.getUuid() + "", new Credentials("cloudsigma", "cloudsigma")); + credentialStore.put("node#"+ from.getUuid(), new Credentials("cloudsigma", "cloudsigma")); return from; } diff --git a/providers/cloudsigma-zrh/src/main/java/org/jclouds/cloudsigma/compute/functions/ServerInfoToNodeMetadata.java b/providers/cloudsigma-zrh/src/main/java/org/jclouds/cloudsigma/compute/functions/ServerInfoToNodeMetadata.java index d8f66ed7bb..4e3df7c015 100644 --- a/providers/cloudsigma-zrh/src/main/java/org/jclouds/cloudsigma/compute/functions/ServerInfoToNodeMetadata.java +++ b/providers/cloudsigma-zrh/src/main/java/org/jclouds/cloudsigma/compute/functions/ServerInfoToNodeMetadata.java @@ -107,7 +107,7 @@ public class ServerInfoToNodeMetadata implements Function of(from.getVnc().getIp())); builder.privateAddresses(ImmutableSet. of()); - builder.credentials(credentialStore.get(from.getUuid())); + builder.credentials(credentialStore.get("node#"+ from.getUuid())); return builder.build(); } From 17545cca295fb94b71a40fd6fdac4d28b16a0ccb Mon Sep 17 00:00:00 2001 From: Adrian Cole Date: Thu, 7 Jul 2011 01:06:01 -0700 Subject: [PATCH 099/264] fixed credential persistence in gogrid --- .../functions/ServerToNodeMetadata.java | 10 ++++----- .../strategy/FindIpThenCreateNodeInGroup.java | 21 ++++++++++++------- .../functions/ServerToNodeMetadataTest.java | 15 +++---------- 3 files changed, 21 insertions(+), 25 deletions(-) diff --git a/providers/gogrid/src/main/java/org/jclouds/gogrid/compute/functions/ServerToNodeMetadata.java b/providers/gogrid/src/main/java/org/jclouds/gogrid/compute/functions/ServerToNodeMetadata.java index 7c0d78070e..355aa664da 100644 --- a/providers/gogrid/src/main/java/org/jclouds/gogrid/compute/functions/ServerToNodeMetadata.java +++ b/providers/gogrid/src/main/java/org/jclouds/gogrid/compute/functions/ServerToNodeMetadata.java @@ -35,8 +35,8 @@ import org.jclouds.compute.domain.Image; import org.jclouds.compute.domain.NodeMetadata; import org.jclouds.compute.domain.NodeMetadataBuilder; import org.jclouds.compute.domain.NodeState; +import org.jclouds.domain.Credentials; import org.jclouds.domain.Location; -import org.jclouds.gogrid.GoGridClient; import org.jclouds.gogrid.domain.Server; import org.jclouds.gogrid.domain.ServerState; import org.jclouds.logging.Logger; @@ -56,10 +56,10 @@ public class ServerToNodeMetadata implements Function { @Resource protected Logger logger = Logger.NULL; private final Map serverStateToNodeState; - private final GoGridClient client; private final Supplier> images; private final Supplier> hardwares; private final Supplier> locations; + private final Map credentialStore; static class FindImageForServer implements Predicate { private final Server instance; @@ -92,11 +92,11 @@ public class ServerToNodeMetadata implements Function { } @Inject - ServerToNodeMetadata(Map serverStateToNodeState, GoGridClient client, + ServerToNodeMetadata(Map serverStateToNodeState, Map credentialStore, @Memoized Supplier> images, @Memoized Supplier> hardwares, Supplier> locations) { this.serverStateToNodeState = checkNotNull(serverStateToNodeState, "serverStateToNodeState"); - this.client = checkNotNull(client, "client"); + this.credentialStore = checkNotNull(credentialStore, "credentialStore"); this.images = checkNotNull(images, "images"); this.hardwares = checkNotNull(hardwares, "hardwares"); this.locations = checkNotNull(locations, "locations"); @@ -118,7 +118,7 @@ public class ServerToNodeMetadata implements Function { builder.state(serverStateToNodeState.get(from.getState())); builder.publicAddresses(ImmutableSet.of(from.getIp().getIp())); - builder.credentials(client.getServerServices().getServerCredentialsList().get(from.getName())); + builder.credentials(credentialStore.get("node#" + from.getId())); return builder.build(); } diff --git a/providers/gogrid/src/main/java/org/jclouds/gogrid/compute/strategy/FindIpThenCreateNodeInGroup.java b/providers/gogrid/src/main/java/org/jclouds/gogrid/compute/strategy/FindIpThenCreateNodeInGroup.java index 5c4ccad148..c32d2068ba 100644 --- a/providers/gogrid/src/main/java/org/jclouds/gogrid/compute/strategy/FindIpThenCreateNodeInGroup.java +++ b/providers/gogrid/src/main/java/org/jclouds/gogrid/compute/strategy/FindIpThenCreateNodeInGroup.java @@ -21,6 +21,7 @@ package org.jclouds.gogrid.compute.strategy; import static com.google.common.base.Preconditions.*; import java.security.SecureRandom; +import java.util.Map; import java.util.Set; import javax.inject.Inject; @@ -31,6 +32,7 @@ import org.jclouds.compute.domain.NodeMetadata; import org.jclouds.compute.domain.Template; import org.jclouds.compute.reference.ComputeServiceConstants.Timeouts; import org.jclouds.compute.strategy.CreateNodeWithGroupEncodedIntoName; +import org.jclouds.domain.Credentials; import org.jclouds.gogrid.GoGridClient; import org.jclouds.gogrid.domain.Ip; import org.jclouds.gogrid.domain.IpType; @@ -52,16 +54,19 @@ public class FindIpThenCreateNodeInGroup implements CreateNodeWithGroupEncodedIn private final GoGridClient client; private final Function sizeToRam; private final Function serverToNodeMetadata; - private RetryablePredicate serverLatestJobCompleted; - private RetryablePredicate serverLatestJobCompletedShort; + private final RetryablePredicate serverLatestJobCompleted; + private final RetryablePredicate serverLatestJobCompletedShort; + private final Map credentialStore; + @Inject - protected FindIpThenCreateNodeInGroup(GoGridClient client, + protected FindIpThenCreateNodeInGroup(GoGridClient client, Map credentialStore, Function serverToNodeMetadata, Function sizeToRam, Timeouts timeouts) { - this.client = client; - this.serverToNodeMetadata = serverToNodeMetadata; - this.sizeToRam = sizeToRam; + this.client = checkNotNull(client, "client"); + this.credentialStore = checkNotNull(credentialStore, "credentialStore"); + this.serverToNodeMetadata = checkNotNull(serverToNodeMetadata, "serverToNodeMetadata"); + this.sizeToRam = checkNotNull(sizeToRam, "sizeToRam"); this.serverLatestJobCompleted = new RetryablePredicate( new ServerLatestJobCompleted(client.getJobServices()), timeouts.nodeRunning * 9l / 10l); @@ -103,12 +108,12 @@ public class FindIpThenCreateNodeInGroup implements CreateNodeWithGroupEncodedIn addedServer = Iterables.getOnlyElement(client.getServerServices().getServersByName( addedServer.getName())); } + credentialStore.put("node#" + addedServer.getId(),client.getServerServices().getServerCredentialsList().get(addedServer.getName())); return serverToNodeMetadata.apply(addedServer); } private Server addServer(String name, Template template, Ip availableIp) { - Server addedServer; - addedServer = client.getServerServices().addServer(name, + Server addedServer = client.getServerServices().addServer(name, checkNotNull(template.getImage().getProviderId()), sizeToRam.apply(template.getHardware()), availableIp.getIp()); return addedServer; diff --git a/providers/gogrid/src/test/java/org/jclouds/gogrid/compute/functions/ServerToNodeMetadataTest.java b/providers/gogrid/src/test/java/org/jclouds/gogrid/compute/functions/ServerToNodeMetadataTest.java index 6fb98d8ea9..0a651f0cdb 100644 --- a/providers/gogrid/src/test/java/org/jclouds/gogrid/compute/functions/ServerToNodeMetadataTest.java +++ b/providers/gogrid/src/test/java/org/jclouds/gogrid/compute/functions/ServerToNodeMetadataTest.java @@ -37,14 +37,12 @@ import org.jclouds.domain.Credentials; import org.jclouds.domain.Location; import org.jclouds.domain.LocationBuilder; import org.jclouds.domain.LocationScope; -import org.jclouds.gogrid.GoGridClient; import org.jclouds.gogrid.compute.suppliers.GoGridHardwareSupplier; import org.jclouds.gogrid.domain.Ip; import org.jclouds.gogrid.domain.Option; import org.jclouds.gogrid.domain.Server; import org.jclouds.gogrid.domain.ServerImage; import org.jclouds.gogrid.domain.ServerState; -import org.jclouds.gogrid.services.GridServerClient; import org.testng.annotations.Test; import com.google.common.base.Suppliers; @@ -61,9 +59,7 @@ public class ServerToNodeMetadataTest { @SuppressWarnings("unchecked") @Test public void testApplySetsTagFromNameAndCredentialsFromName() throws UnknownHostException { - GoGridClient caller = createMock(GoGridClient.class); - GridServerClient client = createMock(GridServerClient.class); - expect(caller.getServerServices()).andReturn(client).atLeastOnce(); + Map serverStateToNodeState = createMock(Map.class); org.jclouds.compute.domain.Image jcImage = createMock(org.jclouds.compute.domain.Image.class); Option dc = new Option(1l, "US-West-1", "US West 1 Datacenter"); @@ -82,8 +78,7 @@ public class ServerToNodeMetadataTest { Map locations = ImmutableMap. of("1", location); Map credentialsMap = createMock(Map.class); - expect(client.getServerCredentialsList()).andReturn(credentialsMap); - expect(credentialsMap.get("group-ff")).andReturn(new Credentials("user", "pass")); + expect(credentialsMap.get("node#1000")).andReturn(new Credentials("user", "pass")); expect(server.getIp()).andReturn(new Ip("127.0.0.1")); @@ -96,15 +91,13 @@ public class ServerToNodeMetadataTest { expect(jcImage.getLocation()).andReturn(location).atLeastOnce(); expect(jcImage.getOperatingSystem()).andReturn(createMock(OperatingSystem.class)).atLeastOnce(); - replay(caller); - replay(client); replay(serverStateToNodeState); replay(server); replay(image); replay(jcImage); replay(credentialsMap); - ServerToNodeMetadata parser = new ServerToNodeMetadata(serverStateToNodeState, caller, Suppliers + ServerToNodeMetadata parser = new ServerToNodeMetadata(serverStateToNodeState, credentialsMap, Suppliers .> ofInstance(images), Suppliers .> ofInstance(GoGridHardwareSupplier.H_ALL), Suppliers .> ofInstance(locations)); @@ -115,8 +108,6 @@ public class ServerToNodeMetadataTest { assertEquals(metadata.getGroup(), "group"); assertEquals(metadata.getCredentials(), new Credentials("user", "pass")); - verify(caller); - verify(client); verify(serverStateToNodeState); verify(image); verify(credentialsMap); From 0e8385aa83c3a41f61ea19c1b509cb63627b0d44 Mon Sep 17 00:00:00 2001 From: Adrian Cole Date: Thu, 7 Jul 2011 01:06:45 -0700 Subject: [PATCH 100/264] Issue 610: greenhouse data now passes --- ...ouseDataElementVCloudComputeServiceLiveTest.java | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/providers/greenhousedata-element-vcloud/src/test/java/org/jclouds/greenhousedata/element/vcloud/compute/GreenHouseDataElementVCloudComputeServiceLiveTest.java b/providers/greenhousedata-element-vcloud/src/test/java/org/jclouds/greenhousedata/element/vcloud/compute/GreenHouseDataElementVCloudComputeServiceLiveTest.java index 9f8e9576d8..0506cccb25 100644 --- a/providers/greenhousedata-element-vcloud/src/test/java/org/jclouds/greenhousedata/element/vcloud/compute/GreenHouseDataElementVCloudComputeServiceLiveTest.java +++ b/providers/greenhousedata-element-vcloud/src/test/java/org/jclouds/greenhousedata/element/vcloud/compute/GreenHouseDataElementVCloudComputeServiceLiveTest.java @@ -18,9 +18,6 @@ */ package org.jclouds.greenhousedata.element.vcloud.compute; -import org.jclouds.compute.domain.Image; -import org.jclouds.compute.domain.Template; -import org.jclouds.compute.domain.TemplateBuilder; import org.jclouds.vcloud.compute.VCloudComputeServiceLiveTest; import org.testng.annotations.Test; @@ -41,13 +38,5 @@ public class GreenHouseDataElementVCloudComputeServiceLiveTest extends VCloudCom public void setServiceDefaults() { group = "director"; } - - @Override - protected Template buildTemplate(TemplateBuilder templateBuilder) { - Template template = super.buildTemplate(templateBuilder); - Image image = template.getImage(); - assert image.getDefaultCredentials().credential != null : image; - return template; - } - + } From 712d50dea835a434f08986bbc54760ac1450cd2e Mon Sep 17 00:00:00 2001 From: Adrian Cole Date: Thu, 7 Jul 2011 01:10:57 -0700 Subject: [PATCH 101/264] avoid finding yourself when looking for a process match --- scriptbuilder/src/main/resources/functions/findPid.sh | 2 +- scriptbuilder/src/test/resources/test_find_pid.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/scriptbuilder/src/main/resources/functions/findPid.sh b/scriptbuilder/src/main/resources/functions/findPid.sh index 2285cd06b9..1018c385ac 100644 --- a/scriptbuilder/src/main/resources/functions/findPid.sh +++ b/scriptbuilder/src/main/resources/functions/findPid.sh @@ -5,7 +5,7 @@ function findPid { return 1 } local PATTERN="$1"; shift - local _FOUND=`ps auxwww|grep "$PATTERN"|grep -v " $0"|grep -v grep|awk '{print $2}'` + local _FOUND=`ps auxwww|grep "$PATTERN"|grep -v " $0"|grep -v grep|grep -v $$|awk '{print $2}'` [ -n "$_FOUND" ] && { export FOUND_PID=$_FOUND return 0 diff --git a/scriptbuilder/src/test/resources/test_find_pid.sh b/scriptbuilder/src/test/resources/test_find_pid.sh index e3364ce2de..fc29b66050 100644 --- a/scriptbuilder/src/test/resources/test_find_pid.sh +++ b/scriptbuilder/src/test/resources/test_find_pid.sh @@ -14,7 +14,7 @@ function findPid { return 1 } local PATTERN="$1"; shift - local _FOUND=`ps auxwww|grep "$PATTERN"|grep -v " $0"|grep -v grep|awk '{print $2}'` + local _FOUND=`ps auxwww|grep "$PATTERN"|grep -v " $0"|grep -v grep|grep -v $$|awk '{print $2}'` [ -n "$_FOUND" ] && { export FOUND_PID=$_FOUND return 0 From 0b4347772bc4d46f2091671c21305aeac89d1809 Mon Sep 17 00:00:00 2001 From: Adrian Cole Date: Thu, 7 Jul 2011 01:12:09 -0700 Subject: [PATCH 102/264] don't exit unless process has already started --- scriptbuilder/src/main/resources/functions/forget.sh | 2 +- scriptbuilder/src/test/resources/test_ebs.sh | 4 ++-- scriptbuilder/src/test/resources/test_init.sh | 4 ++-- scriptbuilder/src/test/resources/test_seek_and_destroy.sh | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/scriptbuilder/src/main/resources/functions/forget.sh b/scriptbuilder/src/main/resources/functions/forget.sh index c8cd4f344a..dbe5c0ce94 100644 --- a/scriptbuilder/src/main/resources/functions/forget.sh +++ b/scriptbuilder/src/main/resources/functions/forget.sh @@ -9,7 +9,7 @@ function forget { local LOG_DIR="$1"; shift mkdir -p $LOG_DIR findPid $INSTANCE_NAME - [ -n "$FOUND_PID" ] && { + [ -n "$FOUND_PID" -a -f $LOG_DIR/stdout.log ] && { echo $INSTANCE_NAME already running pid [$FOUND_PID] } || { nohup $SCRIPT >$LOG_DIR/stdout.log 2>$LOG_DIR/stderr.log & diff --git a/scriptbuilder/src/test/resources/test_ebs.sh b/scriptbuilder/src/test/resources/test_ebs.sh index 69f9b33914..c2d2545518 100644 --- a/scriptbuilder/src/test/resources/test_ebs.sh +++ b/scriptbuilder/src/test/resources/test_ebs.sh @@ -26,7 +26,7 @@ function findPid { return 1 } local PATTERN="$1"; shift - local _FOUND=`ps auxwww|grep "$PATTERN"|grep -v " $0"|grep -v grep|awk '{print $2}'` + local _FOUND=`ps auxwww|grep "$PATTERN"|grep -v " $0"|grep -v grep|grep -v $$|awk '{print $2}'` [ -n "$_FOUND" ] && { export FOUND_PID=$_FOUND return 0 @@ -45,7 +45,7 @@ function forget { local LOG_DIR="$1"; shift mkdir -p $LOG_DIR findPid $INSTANCE_NAME - [ -n "$FOUND_PID" ] && { + [ -n "$FOUND_PID" -a -f $LOG_DIR/stdout.log ] && { echo $INSTANCE_NAME already running pid [$FOUND_PID] } || { nohup $SCRIPT >$LOG_DIR/stdout.log 2>$LOG_DIR/stderr.log & diff --git a/scriptbuilder/src/test/resources/test_init.sh b/scriptbuilder/src/test/resources/test_init.sh index 049824a311..43d48b0a2a 100644 --- a/scriptbuilder/src/test/resources/test_init.sh +++ b/scriptbuilder/src/test/resources/test_init.sh @@ -24,7 +24,7 @@ function findPid { return 1 } local PATTERN="$1"; shift - local _FOUND=`ps auxwww|grep "$PATTERN"|grep -v " $0"|grep -v grep|awk '{print $2}'` + local _FOUND=`ps auxwww|grep "$PATTERN"|grep -v " $0"|grep -v grep|grep -v $$|awk '{print $2}'` [ -n "$_FOUND" ] && { export FOUND_PID=$_FOUND return 0 @@ -43,7 +43,7 @@ function forget { local LOG_DIR="$1"; shift mkdir -p $LOG_DIR findPid $INSTANCE_NAME - [ -n "$FOUND_PID" ] && { + [ -n "$FOUND_PID" -a -f $LOG_DIR/stdout.log ] && { echo $INSTANCE_NAME already running pid [$FOUND_PID] } || { nohup $SCRIPT >$LOG_DIR/stdout.log 2>$LOG_DIR/stderr.log & diff --git a/scriptbuilder/src/test/resources/test_seek_and_destroy.sh b/scriptbuilder/src/test/resources/test_seek_and_destroy.sh index ed83ca9ece..dad6f6dc5b 100644 --- a/scriptbuilder/src/test/resources/test_seek_and_destroy.sh +++ b/scriptbuilder/src/test/resources/test_seek_and_destroy.sh @@ -14,7 +14,7 @@ function findPid { return 1 } local PATTERN="$1"; shift - local _FOUND=`ps auxwww|grep "$PATTERN"|grep -v " $0"|grep -v grep|awk '{print $2}'` + local _FOUND=`ps auxwww|grep "$PATTERN"|grep -v " $0"|grep -v grep|grep -v $$|awk '{print $2}'` [ -n "$_FOUND" ] && { export FOUND_PID=$_FOUND return 0 From bc103209db0f2a070a2898cd985339dad4c80025 Mon Sep 17 00:00:00 2001 From: Adrian Cole Date: Thu, 7 Jul 2011 01:13:20 -0700 Subject: [PATCH 103/264] bug where an init script ran without root privs finds the wrong path --- .../compute/callables/RunScriptOnNodeAsInitScriptUsingSsh.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compute/src/main/java/org/jclouds/compute/callables/RunScriptOnNodeAsInitScriptUsingSsh.java b/compute/src/main/java/org/jclouds/compute/callables/RunScriptOnNodeAsInitScriptUsingSsh.java index 34459c8eb7..1e53468445 100644 --- a/compute/src/main/java/org/jclouds/compute/callables/RunScriptOnNodeAsInitScriptUsingSsh.java +++ b/compute/src/main/java/org/jclouds/compute/callables/RunScriptOnNodeAsInitScriptUsingSsh.java @@ -201,7 +201,7 @@ public class RunScriptOnNodeAsInitScriptUsingSsh implements RunScriptOnNode { } protected String execScriptAsDefaultUser(String action) { - return "./" + initFile + " " + action; + return "./" + init.getInstanceName() + " " + action; } public NodeMetadata getNode() { From 32e4065bb7f6ed1eb79650f2fd7e29c824f0bc63 Mon Sep 17 00:00:00 2001 From: Adrian Cole Date: Thu, 7 Jul 2011 01:14:27 -0700 Subject: [PATCH 104/264] fix runScriptOnNode which wasn't processing options --- .../compute/internal/BaseComputeService.java | 32 ++++++++++++------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/compute/src/main/java/org/jclouds/compute/internal/BaseComputeService.java b/compute/src/main/java/org/jclouds/compute/internal/BaseComputeService.java index 5e078a5e20..af38b47f94 100644 --- a/compute/src/main/java/org/jclouds/compute/internal/BaseComputeService.java +++ b/compute/src/main/java/org/jclouds/compute/internal/BaseComputeService.java @@ -607,7 +607,11 @@ public class BaseComputeService implements ComputeService { if (node.getState() != NodeState.RUNNING) throw new IllegalStateException("node " + id + " needs to be running before executing a script on it. current state: " + node.getState()); - return runScriptOnNodeFactory.create(node, runScript, options).init().call(); + initAdminAccess.visit(runScript); + node = updateNodeWithCredentialsIfPresent(node, options); + ExecResponse response = runScriptOnNodeFactory.create(node, runScript, options).init().call(); + persistNodeCredentials.ifAdminAccess(runScript).apply(node); + return response; } private Iterable transformNodesIntoInitializedScriptRunners( @@ -626,6 +630,20 @@ public class BaseComputeService implements ComputeService { return templateOptionsProvider.get(); } + protected NodeMetadata updateNodeWithCredentialsIfPresent(NodeMetadata node, RunScriptOptions options) { + checkNotNull(node, "node"); + if (options.getOverridingCredentials() != null) { + Builder builder = node.getCredentials() != null ? node.getCredentials().toBuilder() + : new Credentials.Builder(); + if (options.getOverridingCredentials().identity != null) + builder.identity(options.getOverridingCredentials().identity); + if (options.getOverridingCredentials().credential != null) + builder.credential(options.getOverridingCredentials().credential); + node = NodeMetadataBuilder.fromNodeMetadata(node).credentials(builder.build()).build(); + } + return node; + } + private final class TransformNodesIntoInitializedScriptRunners implements Function> { private final Map badNodes; @@ -641,18 +659,10 @@ public class BaseComputeService implements ComputeService { @Override public Future apply(NodeMetadata node) { - checkNotNull(node, "node"); - if (options.getOverridingCredentials() != null) { - Builder builder = node.getCredentials() != null ? node.getCredentials().toBuilder() - : new Credentials.Builder(); - if (options.getOverridingCredentials().identity != null) - builder.identity(options.getOverridingCredentials().identity); - if (options.getOverridingCredentials().credential != null) - builder.credential(options.getOverridingCredentials().credential); - node = NodeMetadataBuilder.fromNodeMetadata(node).credentials(builder.build()).build(); - } + node = updateNodeWithCredentialsIfPresent(node, options); return executor.submit(initScriptRunnerFactory.create(node, script, options, badNodes)); } + } } \ No newline at end of file From c58dba41e9b21447b348415b57efea50fe1e1564 Mon Sep 17 00:00:00 2001 From: Adrian Cole Date: Thu, 7 Jul 2011 01:23:01 -0700 Subject: [PATCH 105/264] Issue 621:don't start test instances with http-accessible services running as root --- .../config/StubComputeServiceAdapter.java | 9 +- .../compute/BaseComputeServiceLiveTest.java | 143 +++++++++-- .../org/jclouds/compute/RunScriptData.java | 65 ++--- .../StubComputeServiceIntegrationTest.java | 85 +++++-- .../test/resources/initscript_with_java.sh | 7 +- .../test/resources/initscript_with_jboss.sh | 104 ++++---- compute/src/test/resources/runscript.sh | 7 +- .../test/resources/runscript_adminUpdate.sh | 140 +++++++++++ compute/src/test/resources/runscript_jboss.sh | 227 ++++++++++++++++++ .../src/test/resources/standalone-basic.xml | 103 ++++++++ 10 files changed, 765 insertions(+), 125 deletions(-) create mode 100644 compute/src/test/resources/runscript_adminUpdate.sh create mode 100644 compute/src/test/resources/runscript_jboss.sh create mode 100644 compute/src/test/resources/standalone-basic.xml diff --git a/compute/src/main/java/org/jclouds/compute/stub/config/StubComputeServiceAdapter.java b/compute/src/main/java/org/jclouds/compute/stub/config/StubComputeServiceAdapter.java index cae56cc3e3..cebdfa18f0 100644 --- a/compute/src/main/java/org/jclouds/compute/stub/config/StubComputeServiceAdapter.java +++ b/compute/src/main/java/org/jclouds/compute/stub/config/StubComputeServiceAdapter.java @@ -63,12 +63,14 @@ public class StubComputeServiceAdapter implements JCloudsNativeComputeServiceAda private final String passwordPrefix; private final Supplier> locationSupplier; private final Map> osToVersionMap; + private final Map credentialStore; @Inject public StubComputeServiceAdapter(ConcurrentMap nodes, Supplier location, @Named("NODE_ID") Provider idProvider, @Named("PUBLIC_IP_PREFIX") String publicIpPrefix, @Named("PRIVATE_IP_PREFIX") String privateIpPrefix, @Named("PASSWORD_PREFIX") String passwordPrefix, - JustProvider locationSupplier, Map> osToVersionMap) { + JustProvider locationSupplier, Map> osToVersionMap, + Map credentialStore) { this.nodes = nodes; this.location = location; this.idProvider = idProvider; @@ -77,6 +79,7 @@ public class StubComputeServiceAdapter implements JCloudsNativeComputeServiceAda this.passwordPrefix = passwordPrefix; this.locationSupplier = locationSupplier; this.osToVersionMap = osToVersionMap; + this.credentialStore = credentialStore; } @Override @@ -140,7 +143,9 @@ public class StubComputeServiceAdapter implements JCloudsNativeComputeServiceAda @Override public NodeMetadata getNode(String id) { - return nodes.get(id); + NodeMetadata node = nodes.get(id); + return node == null ? null : NodeMetadataBuilder.fromNodeMetadata(node).credentials( + credentialStore.get("node#" + node.getId())).build(); } @Override diff --git a/compute/src/test/java/org/jclouds/compute/BaseComputeServiceLiveTest.java b/compute/src/test/java/org/jclouds/compute/BaseComputeServiceLiveTest.java index 0c8c5b5949..6870b90e04 100644 --- a/compute/src/test/java/org/jclouds/compute/BaseComputeServiceLiveTest.java +++ b/compute/src/test/java/org/jclouds/compute/BaseComputeServiceLiveTest.java @@ -17,7 +17,6 @@ * ==================================================================== */ package org.jclouds.compute; - import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Predicates.and; import static com.google.common.base.Predicates.not; @@ -30,11 +29,16 @@ import static com.google.common.collect.Maps.uniqueIndex; import static com.google.common.collect.Sets.filter; import static com.google.common.collect.Sets.newTreeSet; import static java.lang.String.format; +import static java.lang.System.currentTimeMillis; import static java.util.logging.Logger.getAnonymousLogger; import static org.jclouds.compute.ComputeTestUtils.buildScript; +import static org.jclouds.compute.RunScriptData.installAdminUserJBossAndOpenPorts; +import static org.jclouds.compute.RunScriptData.startJBoss; +import static org.jclouds.compute.options.RunScriptOptions.Builder.nameTask; import static org.jclouds.compute.options.RunScriptOptions.Builder.wrapInInitScript; -import static org.jclouds.compute.options.TemplateOptions.Builder.blockOnComplete; +import static org.jclouds.compute.options.TemplateOptions.Builder.inboundPorts; import static org.jclouds.compute.options.TemplateOptions.Builder.overrideCredentialsWith; +import static org.jclouds.compute.options.TemplateOptions.Builder.runAsRoot; import static org.jclouds.compute.predicates.NodePredicates.TERMINATED; import static org.jclouds.compute.predicates.NodePredicates.all; import static org.jclouds.compute.predicates.NodePredicates.inGroup; @@ -55,6 +59,8 @@ import java.util.Map.Entry; import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; +import java.util.regex.Matcher; +import java.util.regex.Pattern; import org.jclouds.Constants; import org.jclouds.compute.domain.ComputeMetadata; @@ -82,6 +88,7 @@ import org.jclouds.scriptbuilder.domain.Statements; import org.jclouds.scriptbuilder.statements.login.AdminAccess; import org.jclouds.ssh.SshClient; import org.jclouds.ssh.SshException; +import org.jclouds.util.Strings2; import org.testng.annotations.AfterTest; import org.testng.annotations.BeforeGroups; import org.testng.annotations.Test; @@ -89,6 +96,7 @@ import org.testng.annotations.Test; import com.google.common.base.Function; import com.google.common.base.Predicate; import com.google.common.base.Predicates; +import com.google.common.base.Supplier; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Iterables; import com.google.inject.Guice; @@ -103,7 +111,8 @@ public abstract class BaseComputeServiceLiveTest { protected String group; - protected RetryablePredicate socketTester; + protected Predicate socketTester; + protected Predicate preciseSocketTester; protected SortedSet nodes; protected ComputeServiceContext context; protected ComputeService client; @@ -117,6 +126,7 @@ public abstract class BaseComputeServiceLiveTest { protected String endpoint; protected String apiversion; + protected Properties setupProperties() { Properties overrides = new Properties(); overrides.setProperty(Constants.PROPERTY_TRUST_ALL_CERTS, "true"); @@ -175,6 +185,12 @@ public abstract class BaseComputeServiceLiveTest { protected void buildSocketTester() { SocketOpen socketOpen = Guice.createInjector(getSshModule()).getInstance(SocketOpen.class); socketTester = new RetryablePredicate(socketOpen, 60, 1, TimeUnit.SECONDS); + // wait a maximum of 30 seconds for port 8080 to open. + long maxWait = TimeUnit.SECONDS.toMillis(30); + long interval = 50; + // get more precise than default socket tester + preciseSocketTester = new RetryablePredicate(socketOpen, maxWait, interval, interval, + TimeUnit.MILLISECONDS); } abstract protected Module getSshModule(); @@ -201,9 +217,9 @@ public abstract class BaseComputeServiceLiveTest { @Test(enabled = true) public void testImagesCache() throws Exception { client.listImages(); - long time = System.currentTimeMillis(); + long time = currentTimeMillis(); client.listImages(); - long duration = System.currentTimeMillis() - time; + long duration = currentTimeMillis() - time; assert duration < 1000 : format("%dms to get images", duration); } @@ -255,6 +271,14 @@ public abstract class BaseComputeServiceLiveTest { checkNodes(nodes, group); + // test adding AdminAccess later changes the default boot user, in this case to foo + response = client.runScriptOnNode(get(nodes, 0).getId(), AdminAccess.builder().adminUsername("foo").build(), nameTask("adminUpdate")); + + response = client.runScriptOnNode(get(nodes, 0).getId(), "echo $USER", wrapInInitScript(false) + .runAsRoot(false)); + + assert response.getOutput().trim().equals("foo") : get(nodes, 0).getId() + ": " + response; + } finally { client.destroyNodesMatching(inGroup(group)); } @@ -509,27 +533,114 @@ public abstract class BaseComputeServiceLiveTest { return filter(client.listNodesDetailsMatching(all()), and(inGroup(group), not(TERMINATED))); } + static class ServiceStats { + long backgroundProcessSeconds; + long socketOpenMilliseconds; + long reportedStartupTimeMilliseconds; + + @Override + public String toString() { + return String.format( + "[backgroundProcessSeconds=%s, socketOpenMilliseconds=%s, reportedStartupTimeMilliseconds=%s]", + backgroundProcessSeconds, socketOpenMilliseconds, reportedStartupTimeMilliseconds); + } + } + + protected ServiceStats trackAvailabilityOfProcessOnNode(Supplier bgProcess, String processName, + NodeMetadata node, Pattern parseReported) { + ServiceStats stats = new ServiceStats(); + long startSeconds = currentTimeMillis(); + + ExecResponse exec = bgProcess.get(); + stats.backgroundProcessSeconds = (currentTimeMillis() - startSeconds) / 1000; + + IPSocket socket = new IPSocket(Iterables.get(node.getPublicAddresses(), 0), 8080); + assert preciseSocketTester.apply(socket) : node; + stats.socketOpenMilliseconds = currentTimeMillis() - startSeconds; + + exec = client.runScriptOnNode(node.getId(), "./" + processName + " tail", runAsRoot(false) + .wrapInInitScript(false)); + + Matcher matcher = parseReported.matcher(exec.getOutput()); + if (matcher.find()) + stats.reportedStartupTimeMilliseconds = new Long(matcher.group(1)); + + getAnonymousLogger().info(format("<< %s on node(%s) %s", bgProcess, node.getId(), stats)); + return stats; + } + + // started in 6462ms - + public static final Pattern JBOSS_PATTERN = Pattern.compile("started in ([0-9]+)ms -"); + + protected ServiceStats trackAvailabilityOfJBossProcessOnNode(Supplier startProcess, NodeMetadata node) { + return trackAvailabilityOfProcessOnNode(startProcess, "jboss", node, JBOSS_PATTERN); + } + @Test(enabled = true) public void testCreateAndRunAService() throws Exception { String group = this.group + "s"; + final String configuration = Strings2.toStringAndClose(RunScriptData.class + .getResourceAsStream("/standalone-basic.xml")); try { client.destroyNodesMatching(inGroup(group)); } catch (Exception e) { } - template = client.templateBuilder().options(blockOnComplete(false).blockOnPort(8080, 600).inboundPorts(22, 8080)) - .build(); - - // note this is a dependency on the template resolution - template.getOptions().runScript( - RunScriptData.createScriptInstallAndStartJBoss(template.getImage() - .getOperatingSystem())); try { - NodeMetadata node = getOnlyElement(client.createNodesInGroup(group, 1, template)); + long startSeconds = currentTimeMillis(); + NodeMetadata node = getOnlyElement(client.createNodesInGroup(group, 1, inboundPorts(22, 8080).blockOnPort(22, + 300))); + final String nodeId = node.getId(); + long createSeconds = (currentTimeMillis() - startSeconds) / 1000; + + getAnonymousLogger().info( + format("<< available node(%s) os(%s) in %ss", node.getId(), node.getOperatingSystem(), createSeconds)); + + startSeconds = currentTimeMillis(); + + // note this is a dependency on the template resolution so we have the right process per + // operating system. moreover, we wish this to run as root, so that it can change ip + // tables rules and setup our admin user + client.runScriptOnNode(nodeId, installAdminUserJBossAndOpenPorts(node.getOperatingSystem()), + nameTask("configure-jboss")); + + long configureSeconds = (currentTimeMillis() - startSeconds) / 1000; + + getAnonymousLogger().info(format("<< configured node(%s) in %ss", nodeId, configureSeconds)); + + trackAvailabilityOfJBossProcessOnNode(new Supplier() { + + @Override + public ExecResponse get() { + return client.runScriptOnNode(nodeId, startJBoss(configuration), runAsRoot(false).blockOnComplete(false) + .nameTask("jboss")); + } + + @Override + public String toString() { + return "initial start of jboss"; + } + + }, node); + + client.runScriptOnNode(nodeId, "./jboss stop", runAsRoot(false).wrapInInitScript(false)); + + trackAvailabilityOfJBossProcessOnNode(new Supplier() { + + @Override + public ExecResponse get() { + return client.runScriptOnNode(nodeId, "./jboss start", runAsRoot(false).wrapInInitScript(false)); + } + + @Override + public String toString() { + return "warm start of jboss"; + } + + }, node); - checkHttpGet(node); } finally { client.destroyNodesMatching(inGroup(group)); } @@ -595,11 +706,11 @@ public abstract class BaseComputeServiceLiveTest { // no inbound ports TemplateOptions options = client.templateOptions().blockUntilRunning(false).inboundPorts(); try { - long time = System.currentTimeMillis(); + long time = currentTimeMillis(); Set nodes = client.createNodesInGroup(group, 1, options); NodeMetadata node = getOnlyElement(nodes); assert node.getState() != NodeState.RUNNING; - long duration = (System.currentTimeMillis() - time) / 1000; + long duration = (currentTimeMillis() - time) / 1000; assert duration < nonBlockDurationSeconds : format("duration(%d) longer than expected(%d) seconds! ", duration, nonBlockDurationSeconds); } finally { diff --git a/compute/src/test/java/org/jclouds/compute/RunScriptData.java b/compute/src/test/java/org/jclouds/compute/RunScriptData.java index 661266a4a3..37849abda9 100644 --- a/compute/src/test/java/org/jclouds/compute/RunScriptData.java +++ b/compute/src/test/java/org/jclouds/compute/RunScriptData.java @@ -18,24 +18,28 @@ */ package org.jclouds.compute; +import static java.lang.String.format; import static org.jclouds.compute.util.ComputeServiceUtils.execHttpResponse; import static org.jclouds.compute.util.ComputeServiceUtils.extractTargzIntoDirectory; +import static org.jclouds.scriptbuilder.domain.Statements.appendFile; import static org.jclouds.scriptbuilder.domain.Statements.exec; import static org.jclouds.scriptbuilder.domain.Statements.interpret; import static org.jclouds.scriptbuilder.domain.Statements.newStatementList; +import java.io.IOException; import java.net.URI; -import java.util.Map; import org.jclouds.compute.domain.OperatingSystem; import org.jclouds.compute.predicates.OperatingSystemPredicates; import org.jclouds.scriptbuilder.InitBuilder; import org.jclouds.scriptbuilder.domain.Statement; -import org.jclouds.scriptbuilder.domain.Statements; +import org.jclouds.scriptbuilder.domain.StatementList; import org.jclouds.scriptbuilder.statements.login.AdminAccess; +import com.google.common.base.Splitter; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableList.Builder; /** * @@ -56,31 +60,35 @@ public class RunScriptData { throw new IllegalArgumentException("don't know how to handle" + os.toString()); } - public static Statement authorizePortInIpTables(int port) { - return Statements.newStatementList(// just in case iptables are being used, try to open 8080 - exec("iptables -I INPUT 1 -p tcp --dport " + port + " -j ACCEPT"),// - // TODO gogrid rules only allow ports 22, 3389, 80 and 443. - // the above rule will be ignored, so we have to apply this - // directly - exec("iptables -I RH-Firewall-1-INPUT 1 -p tcp --dport " + port + " -j ACCEPT"),// - exec("iptables-save")); + public static Statement authorizePortsInIpTables(int... ports) { + Builder builder = ImmutableList. builder(); + for (int port : ports) + builder.add(exec("iptables -I INPUT 1 -p tcp --dport " + port + " -j ACCEPT")); + builder.add(exec("iptables-save")); + return new StatementList(builder.build()); } - public static Statement createScriptInstallAndStartJBoss(OperatingSystem os) { - Map envVariables = ImmutableMap.of("jbossHome", jbossHome); - Statement toReturn = new InitBuilder( - "jboss", - jbossHome, - jbossHome, - envVariables, - ImmutableList. of(AdminAccess.standard(),// + public static StatementList installAdminUserJBossAndOpenPorts(OperatingSystem os) throws IOException { + return new StatementList(// + AdminAccess.builder().adminUsername("web").build(),// installJavaAndCurl(os),// - authorizePortInIpTables(8080), - extractTargzIntoDirectory(URI.create(System.getProperty("test.jboss-url", + authorizePortsInIpTables(22, 8080),// + extractTargzIntoDirectory(URI.create(System.getProperty("test.jboss-url",// "http://d37gkgjhl3prlk.cloudfront.net/jboss-7.0.0.CR1.tar.gz")), "/usr/local"),// exec("{md} " + jbossHome), exec("mv /usr/local/jboss-*/* " + jbossHome),// changeStandaloneConfigToListenOnAllIPAddresses(), - exec("chmod -R oug+r+w " + jbossHome)),// + exec("chmod -R oug+r+w " + jbossHome), + exec("chown -R web " + jbossHome)); + } + + // NOTE do not name this the same as your login user, or the init process may kill you! + public static InitBuilder startJBoss(String configuration) { + return new InitBuilder( + "jboss", + jbossHome, + jbossHome, + ImmutableMap.of("jbossHome", jbossHome), + ImmutableList.of(appendFile(jbossHome + "/standalone/configuration/standalone-custom.xml", Splitter.on('\n').split(configuration))), ImmutableList . of(interpret(new StringBuilder().append("java ").append(' ') .append("-server -Xms128m -Xmx128m -XX:MaxPermSize=128m -Djava.net.preferIPv4Stack=true -XX:+UseFastAccessorMethods -XX:+TieredCompilation -Xverify:none -Dorg.jboss.resolver.warning=true -Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.dgc.server.gcInterval=3600000").append(' ') @@ -92,9 +100,9 @@ public class RunScriptData { .append("-logmodule org.jboss.logmanager").append(' ') .append("-jaxpmodule javax.xml.jaxp-provider").append(' ') .append("org.jboss.as.standalone").append(' ') - .append("-Djboss.home.dir=$JBOSS_HOME") + .append("-Djboss.home.dir=$JBOSS_HOME").append(' ') + .append("--server-config=standalone-custom.xml") .toString()))); - return toReturn; } public static Statement normalizeHostAndDNSConfig() { @@ -118,7 +126,9 @@ public class RunScriptData { // TODO make this a cli option private static Statement changeStandaloneConfigToListenOnAllIPAddresses() { - return exec("(cd $JBOSS_HOME/standalone/configuration && sed 's~inet-address value=.*/~any-address/~g' standalone.xml > standalone.xml.new && mv standalone.xml.new standalone.xml)"); + return exec(format( + "(cd %s/standalone/configuration && sed 's~inet-address value=.*/~any-address/~g' standalone.xml > standalone.xml.new && mv standalone.xml.new standalone.xml)", + jbossHome)); } public static String aptInstall = "apt-get install -f -y -qq --force-yes"; @@ -129,8 +139,7 @@ public class RunScriptData { exec("apt-get update -qq"), exec("which curl || " + aptInstall + " curl"),// exec(aptInstall + " openjdk-6-jdk"),// - exec("rm -rf /var/cache/apt /usr/lib/vmware-tools"),// - exec("echo \"export PATH=\\\"\\$JAVA_HOME/bin/:\\$PATH\\\"\" >> /root/.bashrc")); + exec("echo \"export PATH=\\\"\\$JAVA_HOME/bin/:\\$PATH\\\"\" >> $HOME/.bashrc")); public static String yumInstall = "yum --nogpgcheck -y install"; @@ -138,11 +147,11 @@ public class RunScriptData { normalizeHostAndDNSConfig(),// exec("which curl || " + yumInstall + " curl"),// exec(yumInstall + " java-1.6.0-openjdk-devel"),// - exec("echo \"export PATH=\\\"\\$JAVA_HOME/bin/:\\$PATH\\\"\" >> /root/.bashrc")); + exec("echo \"export PATH=\\\"\\$JAVA_HOME/bin/:\\$PATH\\\"\" >> /etc/bashrc")); public static final Statement ZYPPER_RUN_SCRIPT = newStatementList(// normalizeHostAndDNSConfig(),// exec("which curl || zypper install curl"),// exec("zypper install java-1.6.0-openjdk"),// - exec("echo \"export PATH=\\\"\\$JAVA_HOME/bin/:\\$PATH\\\"\" >> /root/.bashrc")); + exec("echo \"export PATH=\\\"\\$JAVA_HOME/bin/:\\$PATH\\\"\" >> /etc/bashrc")); } diff --git a/compute/src/test/java/org/jclouds/compute/StubComputeServiceIntegrationTest.java b/compute/src/test/java/org/jclouds/compute/StubComputeServiceIntegrationTest.java index da5ec2ad4f..12739b02c2 100644 --- a/compute/src/test/java/org/jclouds/compute/StubComputeServiceIntegrationTest.java +++ b/compute/src/test/java/org/jclouds/compute/StubComputeServiceIntegrationTest.java @@ -81,15 +81,14 @@ public class StubComputeServiceIntegrationTest extends BaseComputeServiceLiveTes protected void buildSocketTester() { SocketOpen socketOpen = createMock(SocketOpen.class); - expect(socketOpen.apply(new IPSocket("144.175.1.1", 22))).andReturn(true); - expect(socketOpen.apply(new IPSocket("144.175.1.2", 22))).andReturn(true); - expect(socketOpen.apply(new IPSocket("144.175.1.3", 22))).andReturn(true); - expect(socketOpen.apply(new IPSocket("144.175.1.4", 22))).andReturn(true); - expect(socketOpen.apply(new IPSocket("144.175.1.5", 22))).andReturn(true); + expect(socketOpen.apply(new IPSocket("144.175.1.1", 22))).andReturn(true).times(5); + // restart of jboss + expect(socketOpen.apply(new IPSocket("144.175.1.1", 8080))).andReturn(true).times(2); + replay(socketOpen); - socketTester = new RetryablePredicate(socketOpen, 60, 1, TimeUnit.SECONDS); + preciseSocketTester = socketTester = new RetryablePredicate(socketOpen, 1, 1, TimeUnit.MILLISECONDS); } @Override @@ -136,18 +135,24 @@ public class StubComputeServiceIntegrationTest extends BaseComputeServiceLiveTes SshClient client1 = createMock(SshClient.class); SshClient client1New = createMock(SshClient.class); SshClient client2 = createMock(SshClient.class); + SshClient client2New = createMock(SshClient.class); + SshClient client2Foo = createMock(SshClient.class); SshClient client3 = createMock(SshClient.class); SshClient client4 = createMock(SshClient.class); SshClient client5 = createMock(SshClient.class); expect(factory.create(new IPSocket("144.175.1.1", 22), new Credentials("root", "password1"))).andReturn( client1); - expect(factory.create(new IPSocket("144.175.1.1", 22), new Credentials("defaultAdminUsername", "privateKey"))).andReturn( - client1New); + expect(factory.create(new IPSocket("144.175.1.1", 22), new Credentials("web", "privateKey"))).andReturn( + client1New).times(5); runScriptAndService(client1, client1New); expect(factory.create(new IPSocket("144.175.1.2", 22), new Credentials("root", "password2"))).andReturn( client2).times(4); + expect(factory.create(new IPSocket("144.175.1.2", 22), new Credentials("root", "password2"))).andReturn( + client2New); + expect(factory.create(new IPSocket("144.175.1.2", 22), new Credentials("foo", "privateKey"))).andReturn( + client2Foo); expect(factory.create(new IPSocket("144.175.1.2", 22), new Credentials("root", "romeo"))).andThrow( new SshException("Auth fail")); @@ -171,6 +176,24 @@ public class StubComputeServiceIntegrationTest extends BaseComputeServiceLiveTes } client2.disconnect(); + client2New.connect(); + try { + runScript(client2New, "adminUpdate", + Strings2.toStringAndClose(StubComputeServiceIntegrationTest.class + .getResourceAsStream("/runscript_adminUpdate.sh")), 2); + } catch (IOException e) { + Throwables.propagate(e); + } + client2New.disconnect(); + + // check id + client2Foo.connect(); + expect(client2Foo.getUsername()).andReturn("foo").atLeastOnce(); + expect(client2Foo.getHostAddress()).andReturn("foo").atLeastOnce(); + expect(client2Foo.exec("echo $USER\n")).andReturn(new ExecResponse("foo\n", "", 0)); + client2Foo.disconnect(); + + expect(factory.create(new IPSocket("144.175.1.3", 22), new Credentials("root", "password3"))).andReturn( client3).times(2); expect(factory.create(new IPSocket("144.175.1.4", 22), new Credentials("root", "password4"))).andReturn( @@ -207,6 +230,8 @@ public class StubComputeServiceIntegrationTest extends BaseComputeServiceLiveTes replay(client1); replay(client1New); replay(client2); + replay(client2New); + replay(client2Foo); replay(client3); replay(client4); replay(client5); @@ -218,26 +243,50 @@ public class StubComputeServiceIntegrationTest extends BaseComputeServiceLiveTes client.connect(); try { - String scriptName = "jboss"; + String scriptName = "configure-jboss"; client.put("/tmp/init-" + scriptName, Strings2.toStringAndClose(StubComputeServiceIntegrationTest.class .getResourceAsStream("/initscript_with_jboss.sh"))); expect(client.exec("chmod 755 /tmp/init-" + scriptName)).andReturn(EXEC_GOOD); expect(client.exec("ln -fs /tmp/init-" + scriptName + " " + scriptName)).andReturn(EXEC_GOOD); expect(client.getUsername()).andReturn("root").atLeastOnce(); - expect(client.getHostAddress()).andReturn(clientNew + "").atLeastOnce(); + expect(client.getHostAddress()).andReturn("localhost").atLeastOnce(); expect(client.exec("./" + scriptName + " init")).andReturn(EXEC_GOOD); + expect(client.exec("./" + scriptName + " start")).andReturn(EXEC_GOOD); + expect(client.exec("./" + scriptName + " status")).andReturn(EXEC_GOOD); + // next status says the script is done, since not found. + expect(client.exec("./" + scriptName + " status")).andReturn(EXEC_BAD); + expect(client.exec("./" + scriptName + " tail")).andReturn(EXEC_GOOD); + expect(client.exec("./" + scriptName + " tailerr")).andReturn(EXEC_GOOD); // note we have to reconnect here, as we updated the login user. client.disconnect(); + clientNew.connect(); - expect(clientNew.getUsername()).andReturn("defaultAdminUsername").atLeastOnce(); - expect(clientNew.getHostAddress()).andReturn(clientNew + "").atLeastOnce(); + scriptName = "jboss"; + clientNew.put("/tmp/init-" + scriptName, Strings2 + .toStringAndClose(StubComputeServiceIntegrationTest.class + .getResourceAsStream("/runscript_jboss.sh"))); + expect(clientNew.exec("chmod 755 /tmp/init-" + scriptName)).andReturn(EXEC_GOOD); expect(clientNew.exec("ln -fs /tmp/init-" + scriptName + " " + scriptName)).andReturn(EXEC_GOOD); - expect(clientNew.exec("sudo ./" + scriptName + " start")).andReturn(EXEC_GOOD); - expect(clientNew.exec("sudo ./" + scriptName + " status")).andReturn(EXEC_GOOD); - // next status says the script is done, since not found. - expect(clientNew.exec("sudo ./" + scriptName + " status")).andReturn(EXEC_BAD); - expect(clientNew.exec("sudo ./" + scriptName + " tail")).andReturn(EXEC_GOOD); - expect(clientNew.exec("sudo ./" + scriptName + " tailerr")).andReturn(EXEC_GOOD); + expect(clientNew.getUsername()).andReturn("web").atLeastOnce(); + expect(clientNew.getHostAddress()).andReturn("localhost").atLeastOnce(); + expect(clientNew.exec("./" + scriptName + " init")).andReturn(EXEC_GOOD); + expect(clientNew.exec("./" + scriptName + " start")).andReturn(EXEC_GOOD); + clientNew.disconnect(); + clientNew.connect(); + expect(clientNew.exec("./" + scriptName + " tail\n")).andReturn(EXEC_GOOD); + clientNew.disconnect(); + + clientNew.connect(); + expect(clientNew.exec("./" + scriptName + " stop\n")).andReturn(EXEC_GOOD); + clientNew.disconnect(); + + clientNew.connect(); + expect(clientNew.exec("./" + scriptName + " start\n")).andReturn(EXEC_GOOD); + clientNew.disconnect(); + + clientNew.connect(); + expect(clientNew.exec("./" + scriptName + " tail\n")).andReturn(EXEC_GOOD); + clientNew.disconnect(); } catch (IOException e) { Throwables.propagate(e); } diff --git a/compute/src/test/resources/initscript_with_java.sh b/compute/src/test/resources/initscript_with_java.sh index 7ae463a98e..c5a9745772 100644 --- a/compute/src/test/resources/initscript_with_java.sh +++ b/compute/src/test/resources/initscript_with_java.sh @@ -23,7 +23,7 @@ function findPid { return 1 } local PATTERN="$1"; shift - local _FOUND=`ps auxwww|grep "$PATTERN"|grep -v " $0"|grep -v grep|awk '{print $2}'` + local _FOUND=`ps auxwww|grep "$PATTERN"|grep -v " $0"|grep -v grep|grep -v $$|awk '{print $2}'` [ -n "$_FOUND" ] && { export FOUND_PID=$_FOUND return 0 @@ -42,7 +42,7 @@ function forget { local LOG_DIR="$1"; shift mkdir -p $LOG_DIR findPid $INSTANCE_NAME - [ -n "$FOUND_PID" ] && { + [ -n "$FOUND_PID" -a -f $LOG_DIR/stdout.log ] && { echo $INSTANCE_NAME already running pid [$FOUND_PID] } || { nohup $SCRIPT >$LOG_DIR/stdout.log 2>$LOG_DIR/stderr.log & @@ -102,8 +102,7 @@ nslookup yahoo.com >/dev/null || echo nameserver 208.67.222.222 >> /etc/resolv.c apt-get update -qq which curl || apt-get install -f -y -qq --force-yes curl apt-get install -f -y -qq --force-yes openjdk-6-jdk -rm -rf /var/cache/apt /usr/lib/vmware-tools -echo "export PATH=\"\$JAVA_HOME/bin/:\$PATH\"" >> /root/.bashrc +echo "export PATH=\"\$JAVA_HOME/bin/:\$PATH\"" >> $HOME/.bashrc END_OF_SCRIPT diff --git a/compute/src/test/resources/initscript_with_jboss.sh b/compute/src/test/resources/initscript_with_jboss.sh index 0540219d0f..ff92d33337 100644 --- a/compute/src/test/resources/initscript_with_jboss.sh +++ b/compute/src/test/resources/initscript_with_jboss.sh @@ -8,14 +8,13 @@ function abort { exit 1 } function default { - export INSTANCE_NAME="jboss" -export INSTANCE_HOME="/usr/local/jboss" -export LOG_DIR="/usr/local/jboss" + export INSTANCE_NAME="configure-jboss" +export INSTANCE_HOME="/tmp/configure-jboss" +export LOG_DIR="/tmp/configure-jboss" return 0 } -function jboss { - export JBOSS_HOME="/usr/local/jboss" - return 0 +function configure-jboss { + return 0 } function findPid { unset FOUND_PID; @@ -24,7 +23,7 @@ function findPid { return 1 } local PATTERN="$1"; shift - local _FOUND=`ps auxwww|grep "$PATTERN"|grep -v " $0"|grep -v grep|awk '{print $2}'` + local _FOUND=`ps auxwww|grep "$PATTERN"|grep -v " $0"|grep -v grep|grep -v $$|awk '{print $2}'` [ -n "$_FOUND" ] && { export FOUND_PID=$_FOUND return 0 @@ -43,7 +42,7 @@ function forget { local LOG_DIR="$1"; shift mkdir -p $LOG_DIR findPid $INSTANCE_NAME - [ -n "$FOUND_PID" ] && { + [ -n "$FOUND_PID" -a -f $LOG_DIR/stdout.log ] && { echo $INSTANCE_NAME already running pid [$FOUND_PID] } || { nohup $SCRIPT >$LOG_DIR/stdout.log 2>$LOG_DIR/stderr.log & @@ -57,72 +56,71 @@ export PATH=/usr/ucb/bin:/bin:/sbin:/usr/bin:/usr/sbin case $1 in init) default || exit 1 - jboss || exit 1 - rm /etc/sudoers - cat >> /etc/sudoers <<'END_OF_FILE' -root ALL = (ALL) ALL -%wheel ALL = (ALL) NOPASSWD:ALL -END_OF_FILE - chmod 0440 /etc/sudoers - mkdir -p /home/users/defaultAdminUsername - groupadd -f wheel - useradd -s /bin/bash -g wheel -d /home/users/defaultAdminUsername -p 'crypt(randompassword)' defaultAdminUsername - mkdir -p /home/users/defaultAdminUsername/.ssh - cat >> /home/users/defaultAdminUsername/.ssh/authorized_keys <<'END_OF_FILE' -publicKey -END_OF_FILE - chmod 600 /home/users/defaultAdminUsername/.ssh/authorized_keys - chown -R defaultAdminUsername /home/users/defaultAdminUsername - exec 3<> /etc/ssh/sshd_config && awk -v TEXT="PasswordAuthentication no - PermitRootLogin no - " 'BEGIN {print TEXT}{print}' /etc/ssh/sshd_config >&3 - /etc/init.d/sshd reload||/etc/init.d/ssh reload - awk -v user=^${SUDO_USER:=${USER}}: -v password='crypt(randompassword)' 'BEGIN { FS=OFS=":" } $0 ~ user { $2 = password } 1' /etc/shadow >/etc/shadow.${SUDO_USER:=${USER}} - test -f /etc/shadow.${SUDO_USER:=${USER}} && mv /etc/shadow.${SUDO_USER:=${USER}} /etc/shadow - grep `hostname` /etc/hosts >/dev/null || awk -v hostname=`hostname` 'END { print $1" "hostname }' /proc/net/arp >> /etc/hosts - nslookup yahoo.com >/dev/null || echo nameserver 208.67.222.222 >> /etc/resolv.conf - apt-get update -qq - which curl || apt-get install -f -y -qq --force-yes curl - apt-get install -f -y -qq --force-yes openjdk-6-jdk - rm -rf /var/cache/apt /usr/lib/vmware-tools - echo "export PATH=\"\$JAVA_HOME/bin/:\$PATH\"" >> /root/.bashrc - iptables -I INPUT 1 -p tcp --dport 8080 -j ACCEPT - iptables -I RH-Firewall-1-INPUT 1 -p tcp --dport 8080 -j ACCEPT - iptables-save - curl -q -s -S -L --connect-timeout 10 --max-time 600 --retry 20 -X GET http://d37gkgjhl3prlk.cloudfront.net/jboss-7.0.0.CR1.tar.gz |(mkdir -p /usr/local &&cd /usr/local &&tar -xpzf -) - mkdir -p /usr/local/jboss - mv /usr/local/jboss-*/* /usr/local/jboss - (cd $JBOSS_HOME/standalone/configuration && sed 's~inet-address value=.*/~any-address/~g' standalone.xml > standalone.xml.new && mv standalone.xml.new standalone.xml) - chmod -R oug+r+w /usr/local/jboss + configure-jboss || exit 1 mkdir -p $INSTANCE_HOME # create runscript header - cat > $INSTANCE_HOME/jboss.sh < $INSTANCE_HOME/configure-jboss.sh <> $INSTANCE_HOME/jboss.sh <<'END_OF_SCRIPT' + cat >> $INSTANCE_HOME/configure-jboss.sh <<'END_OF_SCRIPT' cd $INSTANCE_HOME -java -server -Xms128m -Xmx128m -XX:MaxPermSize=128m -Djava.net.preferIPv4Stack=true -XX:+UseFastAccessorMethods -XX:+TieredCompilation -Xverify:none -Dorg.jboss.resolver.warning=true -Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.dgc.server.gcInterval=3600000 -Djboss.modules.system.pkgs=org.jboss.byteman -Dorg.jboss.boot.log.file=$JBOSS_HOME/standalone/log/boot.log -Dlogging.configuration=file:$JBOSS_HOME/standalone/configuration/logging.properties -jar $JBOSS_HOME/jboss-modules.jar -mp $JBOSS_HOME/modules -logmodule org.jboss.logmanager -jaxpmodule javax.xml.jaxp-provider org.jboss.as.standalone -Djboss.home.dir=$JBOSS_HOME +rm /etc/sudoers +cat >> /etc/sudoers <<'END_OF_FILE' +root ALL = (ALL) ALL +%wheel ALL = (ALL) NOPASSWD:ALL +END_OF_FILE +chmod 0440 /etc/sudoers +mkdir -p /home/users/web +groupadd -f wheel +useradd -s /bin/bash -g wheel -d /home/users/web -p 'crypt(randompassword)' web +mkdir -p /home/users/web/.ssh +cat >> /home/users/web/.ssh/authorized_keys <<'END_OF_FILE' +publicKey +END_OF_FILE +chmod 600 /home/users/web/.ssh/authorized_keys +chown -R web /home/users/web +exec 3<> /etc/ssh/sshd_config && awk -v TEXT="PasswordAuthentication no +PermitRootLogin no +" 'BEGIN {print TEXT}{print}' /etc/ssh/sshd_config >&3 +/etc/init.d/sshd reload||/etc/init.d/ssh reload +awk -v user=^${SUDO_USER:=${USER}}: -v password='crypt(randompassword)' 'BEGIN { FS=OFS=":" } $0 ~ user { $2 = password } 1' /etc/shadow >/etc/shadow.${SUDO_USER:=${USER}} +test -f /etc/shadow.${SUDO_USER:=${USER}} && mv /etc/shadow.${SUDO_USER:=${USER}} /etc/shadow +grep `hostname` /etc/hosts >/dev/null || awk -v hostname=`hostname` 'END { print $1" "hostname }' /proc/net/arp >> /etc/hosts +nslookup yahoo.com >/dev/null || echo nameserver 208.67.222.222 >> /etc/resolv.conf +apt-get update -qq +which curl || apt-get install -f -y -qq --force-yes curl +apt-get install -f -y -qq --force-yes openjdk-6-jdk +echo "export PATH=\"\$JAVA_HOME/bin/:\$PATH\"" >> $HOME/.bashrc +iptables -I INPUT 1 -p tcp --dport 22 -j ACCEPT +iptables -I INPUT 1 -p tcp --dport 8080 -j ACCEPT +iptables-save +curl -q -s -S -L --connect-timeout 10 --max-time 600 --retry 20 -X GET http://d37gkgjhl3prlk.cloudfront.net/jboss-7.0.0.CR1.tar.gz |(mkdir -p /usr/local &&cd /usr/local &&tar -xpzf -) +mkdir -p /usr/local/jboss +mv /usr/local/jboss-*/* /usr/local/jboss +(cd /usr/local/jboss/standalone/configuration && sed 's~inet-address value=.*/~any-address/~g' standalone.xml > standalone.xml.new && mv standalone.xml.new standalone.xml) +chmod -R oug+r+w /usr/local/jboss +chown -R web /usr/local/jboss + END_OF_SCRIPT # add runscript footer - cat >> $INSTANCE_HOME/jboss.sh <<'END_OF_SCRIPT' + cat >> $INSTANCE_HOME/configure-jboss.sh <<'END_OF_SCRIPT' exit 0 END_OF_SCRIPT - chmod u+x $INSTANCE_HOME/jboss.sh + chmod u+x $INSTANCE_HOME/configure-jboss.sh ;; status) default || exit 1 diff --git a/compute/src/test/resources/runscript.sh b/compute/src/test/resources/runscript.sh index 42dc221bba..8c10b95fa2 100644 --- a/compute/src/test/resources/runscript.sh +++ b/compute/src/test/resources/runscript.sh @@ -23,7 +23,7 @@ function findPid { return 1 } local PATTERN="$1"; shift - local _FOUND=`ps auxwww|grep "$PATTERN"|grep -v " $0"|grep -v grep|awk '{print $2}'` + local _FOUND=`ps auxwww|grep "$PATTERN"|grep -v " $0"|grep -v grep|grep -v $$|awk '{print $2}'` [ -n "$_FOUND" ] && { export FOUND_PID=$_FOUND return 0 @@ -42,7 +42,7 @@ function forget { local LOG_DIR="$1"; shift mkdir -p $LOG_DIR findPid $INSTANCE_NAME - [ -n "$FOUND_PID" ] && { + [ -n "$FOUND_PID" -a -f $LOG_DIR/stdout.log ] && { echo $INSTANCE_NAME already running pid [$FOUND_PID] } || { nohup $SCRIPT >$LOG_DIR/stdout.log 2>$LOG_DIR/stderr.log & @@ -81,8 +81,7 @@ nslookup yahoo.com >/dev/null || echo nameserver 208.67.222.222 >> /etc/resolv.c apt-get update -qq which curl || apt-get install -f -y -qq --force-yes curl apt-get install -f -y -qq --force-yes openjdk-6-jdk -rm -rf /var/cache/apt /usr/lib/vmware-tools -echo "export PATH=\"\$JAVA_HOME/bin/:\$PATH\"" >> /root/.bashrc +echo "export PATH=\"\$JAVA_HOME/bin/:\$PATH\"" >> $HOME/.bashrc END_OF_SCRIPT diff --git a/compute/src/test/resources/runscript_adminUpdate.sh b/compute/src/test/resources/runscript_adminUpdate.sh new file mode 100644 index 0000000000..a2631875d3 --- /dev/null +++ b/compute/src/test/resources/runscript_adminUpdate.sh @@ -0,0 +1,140 @@ +#!/bin/bash +set +u +shopt -s xpg_echo +shopt -s expand_aliases +unset PATH JAVA_HOME LD_LIBRARY_PATH +function abort { + echo "aborting: $@" 1>&2 + exit 1 +} +function default { + export INSTANCE_NAME="adminUpdate" +export INSTANCE_HOME="/tmp/adminUpdate" +export LOG_DIR="/tmp/adminUpdate" + return 0 +} +function adminUpdate { + return 0 +} +function findPid { + unset FOUND_PID; + [ $# -eq 1 ] || { + abort "findPid requires a parameter of pattern to match" + return 1 + } + local PATTERN="$1"; shift + local _FOUND=`ps auxwww|grep "$PATTERN"|grep -v " $0"|grep -v grep|grep -v $$|awk '{print $2}'` + [ -n "$_FOUND" ] && { + export FOUND_PID=$_FOUND + return 0 + } || { + return 1 + } +} +function forget { + unset FOUND_PID; + [ $# -eq 3 ] || { + abort "forget requires parameters INSTANCE_NAME SCRIPT LOG_DIR" + return 1 + } + local INSTANCE_NAME="$1"; shift + local SCRIPT="$1"; shift + local LOG_DIR="$1"; shift + mkdir -p $LOG_DIR + findPid $INSTANCE_NAME + [ -n "$FOUND_PID" -a -f $LOG_DIR/stdout.log ] && { + echo $INSTANCE_NAME already running pid [$FOUND_PID] + } || { + nohup $SCRIPT >$LOG_DIR/stdout.log 2>$LOG_DIR/stderr.log & + sleep 1 + findPid $INSTANCE_NAME + [ -n "$FOUND_PID" ] || abort "$INSTANCE_NAME did not start" + } + return 0 +} +export PATH=/usr/ucb/bin:/bin:/sbin:/usr/bin:/usr/sbin +case $1 in +init) + default || exit 1 + adminUpdate || exit 1 + mkdir -p $INSTANCE_HOME + + # create runscript header + cat > $INSTANCE_HOME/adminUpdate.sh <> $INSTANCE_HOME/adminUpdate.sh <<'END_OF_SCRIPT' +cd $INSTANCE_HOME +rm /etc/sudoers +cat >> /etc/sudoers <<'END_OF_FILE' +root ALL = (ALL) ALL +%wheel ALL = (ALL) NOPASSWD:ALL +END_OF_FILE +chmod 0440 /etc/sudoers +mkdir -p /home/users/foo +groupadd -f wheel +useradd -s /bin/bash -g wheel -d /home/users/foo -p 'crypt(randompassword)' foo +mkdir -p /home/users/foo/.ssh +cat >> /home/users/foo/.ssh/authorized_keys <<'END_OF_FILE' +publicKey +END_OF_FILE +chmod 600 /home/users/foo/.ssh/authorized_keys +chown -R foo /home/users/foo +exec 3<> /etc/ssh/sshd_config && awk -v TEXT="PasswordAuthentication no +PermitRootLogin no +" 'BEGIN {print TEXT}{print}' /etc/ssh/sshd_config >&3 +/etc/init.d/sshd reload||/etc/init.d/ssh reload +awk -v user=^${SUDO_USER:=${USER}}: -v password='crypt(randompassword)' 'BEGIN { FS=OFS=":" } $0 ~ user { $2 = password } 1' /etc/shadow >/etc/shadow.${SUDO_USER:=${USER}} +test -f /etc/shadow.${SUDO_USER:=${USER}} && mv /etc/shadow.${SUDO_USER:=${USER}} /etc/shadow + +END_OF_SCRIPT + + # add runscript footer + cat >> $INSTANCE_HOME/adminUpdate.sh <<'END_OF_SCRIPT' +exit 0 +END_OF_SCRIPT + + chmod u+x $INSTANCE_HOME/adminUpdate.sh + ;; +status) + default || exit 1 + findPid $INSTANCE_NAME || exit 1 + echo [$FOUND_PID] + ;; +stop) + default || exit 1 + findPid $INSTANCE_NAME || exit 1 + [ -n "$FOUND_PID" ] && { + echo stopping $FOUND_PID + kill -9 $FOUND_PID + } + ;; +start) + default || exit 1 + forget $INSTANCE_NAME $INSTANCE_HOME/$INSTANCE_NAME.sh $LOG_DIR || exit 1 + ;; +tail) + default || exit 1 + tail $LOG_DIR/stdout.log + ;; +tailerr) + default || exit 1 + tail $LOG_DIR/stderr.log + ;; +run) + default || exit 1 + $INSTANCE_HOME/$INSTANCE_NAME.sh + ;; +esac +exit 0 diff --git a/compute/src/test/resources/runscript_jboss.sh b/compute/src/test/resources/runscript_jboss.sh new file mode 100644 index 0000000000..29cccdc289 --- /dev/null +++ b/compute/src/test/resources/runscript_jboss.sh @@ -0,0 +1,227 @@ +#!/bin/bash +set +u +shopt -s xpg_echo +shopt -s expand_aliases +unset PATH JAVA_HOME LD_LIBRARY_PATH +function abort { + echo "aborting: $@" 1>&2 + exit 1 +} +function default { + export INSTANCE_NAME="jboss" +export INSTANCE_HOME="/usr/local/jboss" +export LOG_DIR="/usr/local/jboss" + return 0 +} +function jboss { + export JBOSS_HOME="/usr/local/jboss" + return 0 +} +function findPid { + unset FOUND_PID; + [ $# -eq 1 ] || { + abort "findPid requires a parameter of pattern to match" + return 1 + } + local PATTERN="$1"; shift + local _FOUND=`ps auxwww|grep "$PATTERN"|grep -v " $0"|grep -v grep|grep -v $$|awk '{print $2}'` + [ -n "$_FOUND" ] && { + export FOUND_PID=$_FOUND + return 0 + } || { + return 1 + } +} +function forget { + unset FOUND_PID; + [ $# -eq 3 ] || { + abort "forget requires parameters INSTANCE_NAME SCRIPT LOG_DIR" + return 1 + } + local INSTANCE_NAME="$1"; shift + local SCRIPT="$1"; shift + local LOG_DIR="$1"; shift + mkdir -p $LOG_DIR + findPid $INSTANCE_NAME + [ -n "$FOUND_PID" -a -f $LOG_DIR/stdout.log ] && { + echo $INSTANCE_NAME already running pid [$FOUND_PID] + } || { + nohup $SCRIPT >$LOG_DIR/stdout.log 2>$LOG_DIR/stderr.log & + sleep 1 + findPid $INSTANCE_NAME + [ -n "$FOUND_PID" ] || abort "$INSTANCE_NAME did not start" + } + return 0 +} +export PATH=/usr/ucb/bin:/bin:/sbin:/usr/bin:/usr/sbin +case $1 in +init) + default || exit 1 + jboss || exit 1 + cat >> /usr/local/jboss/standalone/configuration/standalone-custom.xml <<'END_OF_FILE' + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +END_OF_FILE + mkdir -p $INSTANCE_HOME + + # create runscript header + cat > $INSTANCE_HOME/jboss.sh <> $INSTANCE_HOME/jboss.sh <<'END_OF_SCRIPT' +cd $INSTANCE_HOME +java -server -Xms128m -Xmx128m -XX:MaxPermSize=128m -Djava.net.preferIPv4Stack=true -XX:+UseFastAccessorMethods -XX:+TieredCompilation -Xverify:none -Dorg.jboss.resolver.warning=true -Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.dgc.server.gcInterval=3600000 -Djboss.modules.system.pkgs=org.jboss.byteman -Dorg.jboss.boot.log.file=$JBOSS_HOME/standalone/log/boot.log -Dlogging.configuration=file:$JBOSS_HOME/standalone/configuration/logging.properties -jar $JBOSS_HOME/jboss-modules.jar -mp $JBOSS_HOME/modules -logmodule org.jboss.logmanager -jaxpmodule javax.xml.jaxp-provider org.jboss.as.standalone -Djboss.home.dir=$JBOSS_HOME --server-config=standalone-custom.xml +END_OF_SCRIPT + + # add runscript footer + cat >> $INSTANCE_HOME/jboss.sh <<'END_OF_SCRIPT' +exit 0 +END_OF_SCRIPT + + chmod u+x $INSTANCE_HOME/jboss.sh + ;; +status) + default || exit 1 + findPid $INSTANCE_NAME || exit 1 + echo [$FOUND_PID] + ;; +stop) + default || exit 1 + findPid $INSTANCE_NAME || exit 1 + [ -n "$FOUND_PID" ] && { + echo stopping $FOUND_PID + kill -9 $FOUND_PID + } + ;; +start) + default || exit 1 + forget $INSTANCE_NAME $INSTANCE_HOME/$INSTANCE_NAME.sh $LOG_DIR || exit 1 + ;; +tail) + default || exit 1 + tail $LOG_DIR/stdout.log + ;; +tailerr) + default || exit 1 + tail $LOG_DIR/stderr.log + ;; +run) + default || exit 1 + $INSTANCE_HOME/$INSTANCE_NAME.sh + ;; +esac +exit 0 diff --git a/compute/src/test/resources/standalone-basic.xml b/compute/src/test/resources/standalone-basic.xml new file mode 100644 index 0000000000..5a967492bc --- /dev/null +++ b/compute/src/test/resources/standalone-basic.xml @@ -0,0 +1,103 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From bde7a9d4c8c701cba65b1a64921f53ecaf1b5766 Mon Sep 17 00:00:00 2001 From: Andrew Phillips Date: Wed, 6 Jul 2011 21:22:50 -0400 Subject: [PATCH 106/264] utils -> util in package names --- .../tweetstore/config/GuiceServletConfig.java | 6 +++--- .../{utils => util}/HttpRequestTask.java | 20 ++++++++++++++++++- .../{utils => util}/ImmutableHttpCommand.java | 20 ++++++++++++++++++- .../config/{utils => util}/TaskQueue.java | 20 ++++++++++++++++++- .../integration/StaxSdkAppServer2.java | 4 ++-- .../{utils => util}/ObjectFields.java | 10 ++++------ 6 files changed, 66 insertions(+), 14 deletions(-) rename demos/tweetstore/runatcloud-tweetstore/src/main/java/org/jclouds/demo/tweetstore/config/{utils => util}/HttpRequestTask.java (83%) rename demos/tweetstore/runatcloud-tweetstore/src/main/java/org/jclouds/demo/tweetstore/config/{utils => util}/ImmutableHttpCommand.java (54%) rename demos/tweetstore/runatcloud-tweetstore/src/main/java/org/jclouds/demo/tweetstore/config/{utils => util}/TaskQueue.java (68%) rename demos/tweetstore/runatcloud-tweetstore/src/test/java/org/jclouds/demo/tweetstore/integration/{utils => util}/ObjectFields.java (92%) diff --git a/demos/tweetstore/runatcloud-tweetstore/src/main/java/org/jclouds/demo/tweetstore/config/GuiceServletConfig.java b/demos/tweetstore/runatcloud-tweetstore/src/main/java/org/jclouds/demo/tweetstore/config/GuiceServletConfig.java index be3f0ce06f..dc63e94f62 100644 --- a/demos/tweetstore/runatcloud-tweetstore/src/main/java/org/jclouds/demo/tweetstore/config/GuiceServletConfig.java +++ b/demos/tweetstore/runatcloud-tweetstore/src/main/java/org/jclouds/demo/tweetstore/config/GuiceServletConfig.java @@ -38,9 +38,9 @@ import javax.servlet.ServletContextEvent; import org.jclouds.blobstore.BlobStoreContext; import org.jclouds.blobstore.BlobStoreContextFactory; -import org.jclouds.demo.tweetstore.config.utils.HttpRequestTask; -import org.jclouds.demo.tweetstore.config.utils.HttpRequestTask.Factory; -import org.jclouds.demo.tweetstore.config.utils.TaskQueue; +import org.jclouds.demo.tweetstore.config.util.HttpRequestTask; +import org.jclouds.demo.tweetstore.config.util.TaskQueue; +import org.jclouds.demo.tweetstore.config.util.HttpRequestTask.Factory; import org.jclouds.demo.tweetstore.controller.AddTweetsController; import org.jclouds.demo.tweetstore.controller.StoreTweetsController; import org.jclouds.http.HttpRequest; diff --git a/demos/tweetstore/runatcloud-tweetstore/src/main/java/org/jclouds/demo/tweetstore/config/utils/HttpRequestTask.java b/demos/tweetstore/runatcloud-tweetstore/src/main/java/org/jclouds/demo/tweetstore/config/util/HttpRequestTask.java similarity index 83% rename from demos/tweetstore/runatcloud-tweetstore/src/main/java/org/jclouds/demo/tweetstore/config/utils/HttpRequestTask.java rename to demos/tweetstore/runatcloud-tweetstore/src/main/java/org/jclouds/demo/tweetstore/config/util/HttpRequestTask.java index 9c35a8c60f..a05314d765 100644 --- a/demos/tweetstore/runatcloud-tweetstore/src/main/java/org/jclouds/demo/tweetstore/config/utils/HttpRequestTask.java +++ b/demos/tweetstore/runatcloud-tweetstore/src/main/java/org/jclouds/demo/tweetstore/config/util/HttpRequestTask.java @@ -1,4 +1,22 @@ -package org.jclouds.demo.tweetstore.config.utils; +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.jclouds.demo.tweetstore.config.util; import static com.google.common.base.Preconditions.checkNotNull; import static com.google.inject.name.Names.bindProperties; diff --git a/demos/tweetstore/runatcloud-tweetstore/src/main/java/org/jclouds/demo/tweetstore/config/utils/ImmutableHttpCommand.java b/demos/tweetstore/runatcloud-tweetstore/src/main/java/org/jclouds/demo/tweetstore/config/util/ImmutableHttpCommand.java similarity index 54% rename from demos/tweetstore/runatcloud-tweetstore/src/main/java/org/jclouds/demo/tweetstore/config/utils/ImmutableHttpCommand.java rename to demos/tweetstore/runatcloud-tweetstore/src/main/java/org/jclouds/demo/tweetstore/config/util/ImmutableHttpCommand.java index 355f98c5e7..be39628035 100644 --- a/demos/tweetstore/runatcloud-tweetstore/src/main/java/org/jclouds/demo/tweetstore/config/utils/ImmutableHttpCommand.java +++ b/demos/tweetstore/runatcloud-tweetstore/src/main/java/org/jclouds/demo/tweetstore/config/util/ImmutableHttpCommand.java @@ -1,4 +1,22 @@ -package org.jclouds.demo.tweetstore.config.utils; +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.jclouds.demo.tweetstore.config.util; import org.jclouds.http.HttpCommand; import org.jclouds.http.HttpRequest; diff --git a/demos/tweetstore/runatcloud-tweetstore/src/main/java/org/jclouds/demo/tweetstore/config/utils/TaskQueue.java b/demos/tweetstore/runatcloud-tweetstore/src/main/java/org/jclouds/demo/tweetstore/config/util/TaskQueue.java similarity index 68% rename from demos/tweetstore/runatcloud-tweetstore/src/main/java/org/jclouds/demo/tweetstore/config/utils/TaskQueue.java rename to demos/tweetstore/runatcloud-tweetstore/src/main/java/org/jclouds/demo/tweetstore/config/util/TaskQueue.java index 617201f875..664ed5ab0e 100644 --- a/demos/tweetstore/runatcloud-tweetstore/src/main/java/org/jclouds/demo/tweetstore/config/utils/TaskQueue.java +++ b/demos/tweetstore/runatcloud-tweetstore/src/main/java/org/jclouds/demo/tweetstore/config/util/TaskQueue.java @@ -1,4 +1,22 @@ -package org.jclouds.demo.tweetstore.config.utils; +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.jclouds.demo.tweetstore.config.util; import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkNotNull; diff --git a/demos/tweetstore/runatcloud-tweetstore/src/test/java/org/jclouds/demo/tweetstore/integration/StaxSdkAppServer2.java b/demos/tweetstore/runatcloud-tweetstore/src/test/java/org/jclouds/demo/tweetstore/integration/StaxSdkAppServer2.java index 0298d0d92b..c91becb696 100644 --- a/demos/tweetstore/runatcloud-tweetstore/src/test/java/org/jclouds/demo/tweetstore/integration/StaxSdkAppServer2.java +++ b/demos/tweetstore/runatcloud-tweetstore/src/test/java/org/jclouds/demo/tweetstore/integration/StaxSdkAppServer2.java @@ -22,8 +22,8 @@ package org.jclouds.demo.tweetstore.integration; import static com.google.common.base.Predicates.instanceOf; import static java.util.Arrays.asList; -import static org.jclouds.demo.tweetstore.integration.utils.ObjectFields.set; -import static org.jclouds.demo.tweetstore.integration.utils.ObjectFields.valueOf; +import static org.jclouds.demo.tweetstore.integration.util.ObjectFields.set; +import static org.jclouds.demo.tweetstore.integration.util.ObjectFields.valueOf; import java.io.File; import java.io.IOException; diff --git a/demos/tweetstore/runatcloud-tweetstore/src/test/java/org/jclouds/demo/tweetstore/integration/utils/ObjectFields.java b/demos/tweetstore/runatcloud-tweetstore/src/test/java/org/jclouds/demo/tweetstore/integration/util/ObjectFields.java similarity index 92% rename from demos/tweetstore/runatcloud-tweetstore/src/test/java/org/jclouds/demo/tweetstore/integration/utils/ObjectFields.java rename to demos/tweetstore/runatcloud-tweetstore/src/test/java/org/jclouds/demo/tweetstore/integration/util/ObjectFields.java index e6c108ab3f..d2bd7e4207 100644 --- a/demos/tweetstore/runatcloud-tweetstore/src/test/java/org/jclouds/demo/tweetstore/integration/utils/ObjectFields.java +++ b/demos/tweetstore/runatcloud-tweetstore/src/test/java/org/jclouds/demo/tweetstore/integration/util/ObjectFields.java @@ -1,7 +1,6 @@ -/* - * @(#)ObjectFields.java 26 May 2011 +/** * - * Copyright © 2010 Andrew Phillips. + * Copyright (C) 2011 Cloud Conscious, LLC. * * ==================================================================== * Licensed under the Apache License, Version 2.0 (the "License"); @@ -12,13 +11,12 @@ * * 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. + * 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.demo.tweetstore.integration.utils; +package org.jclouds.demo.tweetstore.integration.util; import java.lang.reflect.Field; From 2c832fef46523eb69a09267d25405aed05abca38 Mon Sep 17 00:00:00 2001 From: Andrew Phillips Date: Thu, 7 Jul 2011 19:16:00 -0400 Subject: [PATCH 107/264] Switching to a local 1.3-SNAPSHOT version of the emma-maven-plugin to resolve https://cloudbees.zendesk.com/tickets/1198 --- project/pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/project/pom.xml b/project/pom.xml index f294f49910..9fbd5528ee 100644 --- a/project/pom.xml +++ b/project/pom.xml @@ -791,7 +791,7 @@ pageTracker._trackPageview(); org.sonatype.maven.plugin emma-maven-plugin - 1.2 + 1.3-SNAPSHOT org.codehaus.mojo @@ -872,7 +872,7 @@ pageTracker._trackPageview(); org.sonatype.maven.plugin emma-maven-plugin - 1.2 + 1.3-SNAPSHOT maven-jxr-plugin From 94e6d5834e226c63e818e5173ef6eb51525c6b28 Mon Sep 17 00:00:00 2001 From: Andrew Phillips Date: Thu, 7 Jul 2011 19:46:05 -0400 Subject: [PATCH 108/264] Also generating the XML EMMA report as required by the Jenkins EMMA plugin --- project/pom.xml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/project/pom.xml b/project/pom.xml index 9fbd5528ee..f3ce3ede18 100644 --- a/project/pom.xml +++ b/project/pom.xml @@ -792,6 +792,9 @@ pageTracker._trackPageview(); org.sonatype.maven.plugin emma-maven-plugin 1.3-SNAPSHOT + + html,xml + org.codehaus.mojo @@ -873,6 +876,9 @@ pageTracker._trackPageview(); org.sonatype.maven.plugin emma-maven-plugin 1.3-SNAPSHOT + + html,xml + maven-jxr-plugin From 37e6424040513dac7ba9350ea47e0d9e278edfbd Mon Sep 17 00:00:00 2001 From: Adrian Cole Date: Thu, 7 Jul 2011 17:03:32 -0700 Subject: [PATCH 109/264] Issue 557:support Virtacore vCloud Express --- core/src/main/resources/rest.properties | 3 + .../virtacore-vcloudexpress/pom.xml | 142 +++++++++++++++ .../VirtacoreVCloudExpressContextBuilder.java | 51 ++++++ ...rtacoreVCloudExpressPropertiesBuilder.java | 46 +++++ ...irtacoreVCloudExpressProviderMetadata.java | 116 ++++++++++++ ...oudExpressComputeServiceContextModule.java | 38 ++++ ...irtacoreVCloudExpressRestClientModule.java | 41 +++++ ...loudTokenCookieAndAuthorizationHeader.java | 53 ++++++ .../org.jclouds.providers.ProviderMetadata | 1 + .../VirtacoreVCloudExpressProviderTest.java | 36 ++++ ...reVCloudExpressComputeServiceLiveTest.java | 40 +++++ ...eVCloudExpressTemplateBuilderLiveTest.java | 79 ++++++++ .../src/test/resources/log4j.xml | 170 ++++++++++++++++++ 13 files changed, 816 insertions(+) create mode 100644 sandbox-providers/virtacore-vcloudexpress/pom.xml create mode 100644 sandbox-providers/virtacore-vcloudexpress/src/main/java/org/jclouds/virtacore/vcloudexpress/VirtacoreVCloudExpressContextBuilder.java create mode 100644 sandbox-providers/virtacore-vcloudexpress/src/main/java/org/jclouds/virtacore/vcloudexpress/VirtacoreVCloudExpressPropertiesBuilder.java create mode 100644 sandbox-providers/virtacore-vcloudexpress/src/main/java/org/jclouds/virtacore/vcloudexpress/VirtacoreVCloudExpressProviderMetadata.java create mode 100644 sandbox-providers/virtacore-vcloudexpress/src/main/java/org/jclouds/virtacore/vcloudexpress/config/VirtacoreVCloudExpressComputeServiceContextModule.java create mode 100644 sandbox-providers/virtacore-vcloudexpress/src/main/java/org/jclouds/virtacore/vcloudexpress/config/VirtacoreVCloudExpressRestClientModule.java create mode 100644 sandbox-providers/virtacore-vcloudexpress/src/main/java/org/jclouds/virtacore/vcloudexpress/filters/SetVCloudTokenCookieAndAuthorizationHeader.java create mode 100644 sandbox-providers/virtacore-vcloudexpress/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata create mode 100644 sandbox-providers/virtacore-vcloudexpress/src/test/java/org/jclouds/virtacore/vcloudexpress/VirtacoreVCloudExpressProviderTest.java create mode 100644 sandbox-providers/virtacore-vcloudexpress/src/test/java/org/jclouds/virtacore/vcloudexpress/compute/VirtacoreVCloudExpressComputeServiceLiveTest.java create mode 100644 sandbox-providers/virtacore-vcloudexpress/src/test/java/org/jclouds/virtacore/vcloudexpress/compute/VirtacoreVCloudExpressTemplateBuilderLiveTest.java create mode 100644 sandbox-providers/virtacore-vcloudexpress/src/test/resources/log4j.xml diff --git a/core/src/main/resources/rest.properties b/core/src/main/resources/rest.properties index 21fa5249d3..b1c4f1ffea 100644 --- a/core/src/main/resources/rest.properties +++ b/core/src/main/resources/rest.properties @@ -144,6 +144,9 @@ cloudsigma-zrh.contextbuilder=org.jclouds.cloudsigma.CloudSigmaContextBuilder ibm-smartcloud.propertiesbuilder=org.jclouds.ibm.smartcloud.IBMSmartCloudPropertiesBuilder ibm-smartcloud.contextbuilder=org.jclouds.ibm.smartcloud.IBMSmartCloudContextBuilder +virtacore-vcloudexpress.propertiesbuilder=org.jclouds.virtacore.vcloudexpress.VirtacoreVCloudExpressPropertiesBuilder +virtacore-vcloudexpress.contextbuilder=org.jclouds.virtacore.vcloudexpress.VirtacoreVCloudExpressContextBuilder + stub.contextbuilder=org.jclouds.compute.stub.StubComputeServiceContextBuilder # example of where to change your endpoint # bluelock.endpoint=https://express3.bluelock.com/api diff --git a/sandbox-providers/virtacore-vcloudexpress/pom.xml b/sandbox-providers/virtacore-vcloudexpress/pom.xml new file mode 100644 index 0000000000..24d8120cac --- /dev/null +++ b/sandbox-providers/virtacore-vcloudexpress/pom.xml @@ -0,0 +1,142 @@ + + + + + 4.0.0 + + org.jclouds + jclouds-project + 1.1.0-SNAPSHOT + ../../project/pom.xml + + org.jclouds.provider + virtacore-vcloudexpress + jclouds Virtacore vCloud Express provider + vCloud implementation targeted to Virtacore + + + https://vcloud.virtacore.com/api + 1.0 + FIXME_IDENTITY + FIXME_CREDENTIAL + + + + + org.jclouds.api + vcloud + ${project.version} + + + org.jclouds.common + vcloud-common + ${project.version} + test-jar + test + + + org.jclouds.api + vcloud + ${project.version} + test-jar + test + + + org.jclouds + jclouds-core + ${project.version} + test-jar + test + + + org.jclouds + jclouds-compute + ${project.version} + test-jar + test + + + org.jclouds.driver + jclouds-log4j + ${project.version} + test + + + org.jclouds.driver + jclouds-jsch + ${project.version} + test + + + com.jcraft + jsch + test + + + + + + live + + + + org.apache.maven.plugins + maven-surefire-plugin + + + integration + integration-test + + test + + + + + test.virtacore-vcloudexpress.endpoint + ${test.virtacore-vcloudexpress.endpoint} + + + test.virtacore-vcloudexpress.apiversion + ${test.virtacore-vcloudexpress.apiversion} + + + test.virtacore-vcloudexpress.identity + ${test.virtacore-vcloudexpress.identity} + + + test.virtacore-vcloudexpress.credential + ${test.virtacore-vcloudexpress.credential} + + + + + + + + + + + + + + diff --git a/sandbox-providers/virtacore-vcloudexpress/src/main/java/org/jclouds/virtacore/vcloudexpress/VirtacoreVCloudExpressContextBuilder.java b/sandbox-providers/virtacore-vcloudexpress/src/main/java/org/jclouds/virtacore/vcloudexpress/VirtacoreVCloudExpressContextBuilder.java new file mode 100644 index 0000000000..9aa36ef305 --- /dev/null +++ b/sandbox-providers/virtacore-vcloudexpress/src/main/java/org/jclouds/virtacore/vcloudexpress/VirtacoreVCloudExpressContextBuilder.java @@ -0,0 +1,51 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.jclouds.virtacore.vcloudexpress; + +import java.util.List; +import java.util.Properties; + +import org.jclouds.vcloud.VCloudContextBuilder; +import org.jclouds.virtacore.vcloudexpress.config.VirtacoreVCloudExpressComputeServiceContextModule; +import org.jclouds.virtacore.vcloudexpress.config.VirtacoreVCloudExpressRestClientModule; + +import com.google.inject.Module; + +/** + * + * @author Adrian Cole + * + */ +public class VirtacoreVCloudExpressContextBuilder extends VCloudContextBuilder { + + public VirtacoreVCloudExpressContextBuilder(Properties props) { + super(props); + } + + @Override + protected void addContextModule(List modules) { + modules.add(new VirtacoreVCloudExpressComputeServiceContextModule()); + } + + @Override + protected void addClientModule(List modules) { + modules.add(new VirtacoreVCloudExpressRestClientModule()); + } + +} diff --git a/sandbox-providers/virtacore-vcloudexpress/src/main/java/org/jclouds/virtacore/vcloudexpress/VirtacoreVCloudExpressPropertiesBuilder.java b/sandbox-providers/virtacore-vcloudexpress/src/main/java/org/jclouds/virtacore/vcloudexpress/VirtacoreVCloudExpressPropertiesBuilder.java new file mode 100644 index 0000000000..4d5b5b9ed4 --- /dev/null +++ b/sandbox-providers/virtacore-vcloudexpress/src/main/java/org/jclouds/virtacore/vcloudexpress/VirtacoreVCloudExpressPropertiesBuilder.java @@ -0,0 +1,46 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.jclouds.virtacore.vcloudexpress; + +import static org.jclouds.Constants.PROPERTY_ENDPOINT; +import static org.jclouds.Constants.PROPERTY_ISO3166_CODES; +import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_DEFAULT_NETWORK; + +import java.util.Properties; + +import org.jclouds.vcloud.VCloudPropertiesBuilder; + +/** + * + * @author Adrian Cole + */ +public class VirtacoreVCloudExpressPropertiesBuilder extends VCloudPropertiesBuilder { + @Override + protected Properties defaultProperties() { + Properties properties = super.defaultProperties(); + properties.setProperty(PROPERTY_ISO3166_CODES, "US-VA,US-CA"); + properties.setProperty(PROPERTY_ENDPOINT, "https://vcloud.virtacore.com/api"); + properties.setProperty(PROPERTY_VCLOUD_DEFAULT_NETWORK, ".*-Public"); + return properties; + } + + public VirtacoreVCloudExpressPropertiesBuilder(Properties properties) { + super(properties); + } +} diff --git a/sandbox-providers/virtacore-vcloudexpress/src/main/java/org/jclouds/virtacore/vcloudexpress/VirtacoreVCloudExpressProviderMetadata.java b/sandbox-providers/virtacore-vcloudexpress/src/main/java/org/jclouds/virtacore/vcloudexpress/VirtacoreVCloudExpressProviderMetadata.java new file mode 100644 index 0000000000..6ecbfc7596 --- /dev/null +++ b/sandbox-providers/virtacore-vcloudexpress/src/main/java/org/jclouds/virtacore/vcloudexpress/VirtacoreVCloudExpressProviderMetadata.java @@ -0,0 +1,116 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.jclouds.virtacore.vcloudexpress; + +import com.google.common.collect.ImmutableSet; + +import java.net.URI; +import java.util.Set; + +import org.jclouds.providers.BaseProviderMetadata; +import org.jclouds.providers.ProviderMetadata; + +/** + * Implementation of {@link org.jclouds.types.ProviderMetadata} for Virtacore vCloud Express + * + * @author Adrian Cole + */ +public class VirtacoreVCloudExpressProviderMetadata extends BaseProviderMetadata { + + /** + * {@inheritDoc} + */ + @Override + public String getId() { + return "virtacore-vcloudexpress"; + } + + /** + * {@inheritDoc} + */ + @Override + public String getType() { + return ProviderMetadata.COMPUTE_TYPE; + } + + /** + * {@inheritDoc} + */ + @Override + public String getName() { + return "Virtacore vCloud Express"; + } + + /** + * {@inheritDoc} + */ + @Override + public String getIdentityName() { + return "User at Organization (user@org)"; + } + + /** + * {@inheritDoc} + */ + @Override + public String getCredentialName() { + return "Password"; + } + + /** + * {@inheritDoc} + */ + @Override + public URI getHomepage() { + return URI.create("http://www.virtacore.com/vcloud_express.cfm"); + } + + /** + * {@inheritDoc} + */ + @Override + public URI getConsole() { + return URI.create("https://www.virtacore.com/vcloudlogin.cfm"); + } + + /** + * {@inheritDoc} + */ + @Override + public URI getApiDocumentation() { + return URI.create("http://kb.virtacore.com/categories/vCloud+Express/"); + } + + /** + * {@inheritDoc} + */ + @Override + public Set getLinkedServices() { + return ImmutableSet.of("virtacore-vcloudexpress"); + } + + /** + * {@inheritDoc} + */ + @Override + public Set getIso3166Codes() { + return ImmutableSet.of("US-VA","US-CA"); + } + +} diff --git a/sandbox-providers/virtacore-vcloudexpress/src/main/java/org/jclouds/virtacore/vcloudexpress/config/VirtacoreVCloudExpressComputeServiceContextModule.java b/sandbox-providers/virtacore-vcloudexpress/src/main/java/org/jclouds/virtacore/vcloudexpress/config/VirtacoreVCloudExpressComputeServiceContextModule.java new file mode 100644 index 0000000000..effc224048 --- /dev/null +++ b/sandbox-providers/virtacore-vcloudexpress/src/main/java/org/jclouds/virtacore/vcloudexpress/config/VirtacoreVCloudExpressComputeServiceContextModule.java @@ -0,0 +1,38 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.jclouds.virtacore.vcloudexpress.config; + +import org.jclouds.compute.options.TemplateOptions; +import org.jclouds.vcloud.compute.config.VCloudComputeServiceContextModule; +import org.jclouds.vcloud.compute.options.VCloudTemplateOptions; +import org.jclouds.vcloud.domain.network.IpAddressAllocationMode; + +import com.google.inject.Injector; + +/** + * + * @author Adrian Cole + */ +public class VirtacoreVCloudExpressComputeServiceContextModule extends VCloudComputeServiceContextModule { + + @Override + protected TemplateOptions provideTemplateOptions(Injector injector, TemplateOptions options) { + return options.as(VCloudTemplateOptions.class).ipAddressAllocationMode(IpAddressAllocationMode.POOL); + } +} diff --git a/sandbox-providers/virtacore-vcloudexpress/src/main/java/org/jclouds/virtacore/vcloudexpress/config/VirtacoreVCloudExpressRestClientModule.java b/sandbox-providers/virtacore-vcloudexpress/src/main/java/org/jclouds/virtacore/vcloudexpress/config/VirtacoreVCloudExpressRestClientModule.java new file mode 100644 index 0000000000..319aa7b884 --- /dev/null +++ b/sandbox-providers/virtacore-vcloudexpress/src/main/java/org/jclouds/virtacore/vcloudexpress/config/VirtacoreVCloudExpressRestClientModule.java @@ -0,0 +1,41 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.jclouds.virtacore.vcloudexpress.config; + +import org.jclouds.http.RequiresHttp; +import org.jclouds.rest.ConfiguresRestClient; +import org.jclouds.vcloud.config.VCloudRestClientModule; +import org.jclouds.vcloud.filters.SetVCloudTokenCookie; +import org.jclouds.virtacore.vcloudexpress.filters.SetVCloudTokenCookieAndAuthorizationHeader; + +/** + * + * @author Adrian Cole + */ +@RequiresHttp +@ConfiguresRestClient +public class VirtacoreVCloudExpressRestClientModule extends VCloudRestClientModule { + + @Override + protected void configure() { + super.configure(); + bind(SetVCloudTokenCookie.class).to(SetVCloudTokenCookieAndAuthorizationHeader.class); + } + +} diff --git a/sandbox-providers/virtacore-vcloudexpress/src/main/java/org/jclouds/virtacore/vcloudexpress/filters/SetVCloudTokenCookieAndAuthorizationHeader.java b/sandbox-providers/virtacore-vcloudexpress/src/main/java/org/jclouds/virtacore/vcloudexpress/filters/SetVCloudTokenCookieAndAuthorizationHeader.java new file mode 100644 index 0000000000..361e0905ce --- /dev/null +++ b/sandbox-providers/virtacore-vcloudexpress/src/main/java/org/jclouds/virtacore/vcloudexpress/filters/SetVCloudTokenCookieAndAuthorizationHeader.java @@ -0,0 +1,53 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.jclouds.virtacore.vcloudexpress.filters; + +import javax.inject.Inject; +import javax.inject.Provider; +import javax.inject.Singleton; + +import org.jclouds.http.HttpException; +import org.jclouds.http.HttpRequest; +import org.jclouds.http.utils.ModifyRequest; +import org.jclouds.vcloud.VCloudToken; +import org.jclouds.vcloud.filters.SetVCloudTokenCookie; + +/** + * Adds the VCloud Token to the request as a cookie + * + * @author Adrian Cole + * + */ +@Singleton +public class SetVCloudTokenCookieAndAuthorizationHeader extends SetVCloudTokenCookie { + + private final Provider vcloudTokenProvider; + + @Inject + public SetVCloudTokenCookieAndAuthorizationHeader(@VCloudToken Provider authTokenProvider) { + super(authTokenProvider); + this.vcloudTokenProvider = authTokenProvider; + } + + @Override + public HttpRequest filter(HttpRequest request) throws HttpException { + return ModifyRequest.replaceHeader(super.filter(request), "x-vcloud-authorization", vcloudTokenProvider.get()); + } + +} \ No newline at end of file diff --git a/sandbox-providers/virtacore-vcloudexpress/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata b/sandbox-providers/virtacore-vcloudexpress/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata new file mode 100644 index 0000000000..8505807ce7 --- /dev/null +++ b/sandbox-providers/virtacore-vcloudexpress/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata @@ -0,0 +1 @@ +org.jclouds.virtacore.vcloudexpress.VirtacoreVCloudExpressProviderMetadata diff --git a/sandbox-providers/virtacore-vcloudexpress/src/test/java/org/jclouds/virtacore/vcloudexpress/VirtacoreVCloudExpressProviderTest.java b/sandbox-providers/virtacore-vcloudexpress/src/test/java/org/jclouds/virtacore/vcloudexpress/VirtacoreVCloudExpressProviderTest.java new file mode 100644 index 0000000000..4ad921231a --- /dev/null +++ b/sandbox-providers/virtacore-vcloudexpress/src/test/java/org/jclouds/virtacore/vcloudexpress/VirtacoreVCloudExpressProviderTest.java @@ -0,0 +1,36 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.jclouds.virtacore.vcloudexpress; + +import org.jclouds.providers.BaseProviderMetadataTest; +import org.jclouds.providers.ProviderMetadata; +import org.jclouds.virtacore.vcloudexpress.VirtacoreVCloudExpressProviderMetadata; +import org.testng.annotations.Test; + +/** + * + * @author Adrian Cole + */ +@Test(groups = "unit", testName = "VirtacoreVCloudExpressProviderTest") +public class VirtacoreVCloudExpressProviderTest extends BaseProviderMetadataTest { + + public VirtacoreVCloudExpressProviderTest() { + super(new VirtacoreVCloudExpressProviderMetadata(), ProviderMetadata.COMPUTE_TYPE); + } +} diff --git a/sandbox-providers/virtacore-vcloudexpress/src/test/java/org/jclouds/virtacore/vcloudexpress/compute/VirtacoreVCloudExpressComputeServiceLiveTest.java b/sandbox-providers/virtacore-vcloudexpress/src/test/java/org/jclouds/virtacore/vcloudexpress/compute/VirtacoreVCloudExpressComputeServiceLiveTest.java new file mode 100644 index 0000000000..d58ac26dde --- /dev/null +++ b/sandbox-providers/virtacore-vcloudexpress/src/test/java/org/jclouds/virtacore/vcloudexpress/compute/VirtacoreVCloudExpressComputeServiceLiveTest.java @@ -0,0 +1,40 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.jclouds.virtacore.vcloudexpress.compute; + +import org.jclouds.vcloud.compute.VCloudComputeServiceLiveTest; +import org.testng.annotations.Test; + +/** + * + * + * @author Adrian Cole + */ +@Test(groups = "live", enabled = true, singleThreaded = true) +public class VirtacoreVCloudExpressComputeServiceLiveTest extends VCloudComputeServiceLiveTest { + public VirtacoreVCloudExpressComputeServiceLiveTest() { + provider = "virtacore-vcloudexpress"; + } + + @Override + public void setServiceDefaults() { + group = "director"; + } + +} diff --git a/sandbox-providers/virtacore-vcloudexpress/src/test/java/org/jclouds/virtacore/vcloudexpress/compute/VirtacoreVCloudExpressTemplateBuilderLiveTest.java b/sandbox-providers/virtacore-vcloudexpress/src/test/java/org/jclouds/virtacore/vcloudexpress/compute/VirtacoreVCloudExpressTemplateBuilderLiveTest.java new file mode 100644 index 0000000000..d18e566546 --- /dev/null +++ b/sandbox-providers/virtacore-vcloudexpress/src/test/java/org/jclouds/virtacore/vcloudexpress/compute/VirtacoreVCloudExpressTemplateBuilderLiveTest.java @@ -0,0 +1,79 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.jclouds.virtacore.vcloudexpress.compute; + +import static org.jclouds.compute.util.ComputeServiceUtils.getCores; +import static org.testng.Assert.assertEquals; + +import java.io.IOException; +import java.util.Set; + +import org.jclouds.compute.BaseTemplateBuilderLiveTest; +import org.jclouds.compute.domain.OsFamily; +import org.jclouds.compute.domain.OsFamilyVersion64Bit; +import org.jclouds.compute.domain.Template; +import org.testng.annotations.Test; + +import com.google.common.base.Predicate; +import com.google.common.collect.ImmutableSet; + +/** + * + * @author Adrian Cole + */ +@Test(groups = "live") +public class VirtacoreVCloudExpressTemplateBuilderLiveTest extends BaseTemplateBuilderLiveTest { + + public VirtacoreVCloudExpressTemplateBuilderLiveTest() { + provider = "virtacore-vcloudexpress"; + } + + @Override + protected Predicate defineUnsupportedOperatingSystems() { + return new Predicate() { + + @Override + public boolean apply(OsFamilyVersion64Bit input) { + switch (input.family) { + case UBUNTU: + return !input.version.equals(""); + case RHEL: + return !input.version.equals(""); + default: + return true; + } + } + + }; + } + + @Override + public void testDefaultTemplateBuilder() throws IOException { + Template defaultTemplate = context.getComputeService().templateBuilder().build(); + assertEquals(defaultTemplate.getImage().getOperatingSystem().getVersion(), ""); + assertEquals(defaultTemplate.getImage().getOperatingSystem().is64Bit(), true); + assertEquals(defaultTemplate.getImage().getOperatingSystem().getFamily(), OsFamily.UBUNTU); + assertEquals(getCores(defaultTemplate.getHardware()), 1.0d); + } + + @Override + protected Set getIso3166Codes() { + return ImmutableSet. of("US-VA", "US-CA"); + } +} diff --git a/sandbox-providers/virtacore-vcloudexpress/src/test/resources/log4j.xml b/sandbox-providers/virtacore-vcloudexpress/src/test/resources/log4j.xml new file mode 100644 index 0000000000..7343ec00e2 --- /dev/null +++ b/sandbox-providers/virtacore-vcloudexpress/src/test/resources/log4j.xml @@ -0,0 +1,170 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file From 5b82761396a52448d2db96e5628a42b5ca86df9a Mon Sep 17 00:00:00 2001 From: Andrew Phillips Date: Thu, 7 Jul 2011 21:34:30 -0400 Subject: [PATCH 110/264] Added Maps2.fromKeys --- .../src/main/java/org/jclouds/util/Maps2.java | 25 +++++++++++++-- .../test/java/org/jclouds/util/Maps2Test.java | 32 +++++++++++++++++++ 2 files changed, 55 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/org/jclouds/util/Maps2.java b/core/src/main/java/org/jclouds/util/Maps2.java index 869f6b644d..c58d853553 100644 --- a/core/src/main/java/org/jclouds/util/Maps2.java +++ b/core/src/main/java/org/jclouds/util/Maps2.java @@ -26,16 +26,17 @@ import static com.google.common.collect.Maps.filterKeys; import java.util.LinkedHashMap; import java.util.Map; import java.util.Map.Entry; +import java.util.Set; import com.google.common.base.Function; import com.google.common.base.Supplier; import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableMap.Builder; import com.google.common.collect.Maps; import com.google.common.collect.Multimap; -import com.google.common.collect.ImmutableMap.Builder; /** - * General utilities used in jclouds code for {@link Map}s. + * General utilities used in jclouds code for {@link Map Maps}. * * @author Adrian Cole */ @@ -120,5 +121,25 @@ public class Maps2 { return toReturn; } } + + /** + * Constructs a map with the given keys where values are generated by the given function. + * Supports duplicate and {@code null} values, but {@code null} keys are not allowed. + * + * @param the type of the keys + * @param the type of the values + * @param keys the keys to be included in the map. Keys must be non-null + * @param valueFunction the function that produces values for the keys + * @return a map containing the keys from the given set with values which are generated from + * the keys + * @see Maps#uniqueIndex(Iterable, Function) + */ + public static Map fromKeys(Set keys, Function valueFunction) { + Map result = Maps.newHashMapWithExpectedSize(keys.size()); + for (K key : keys) { + result.put(checkNotNull(key), valueFunction.apply(key)); + } + return result; + } } diff --git a/core/src/test/java/org/jclouds/util/Maps2Test.java b/core/src/test/java/org/jclouds/util/Maps2Test.java index f3ebc6c236..085d284387 100644 --- a/core/src/test/java/org/jclouds/util/Maps2Test.java +++ b/core/src/test/java/org/jclouds/util/Maps2Test.java @@ -18,7 +18,11 @@ */ package org.jclouds.util; +import static com.google.common.base.Functions.constant; +import static com.google.common.base.Functions.identity; +import static com.google.common.collect.Sets.newHashSet; import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertTrue; import java.util.Map; @@ -26,6 +30,8 @@ import org.testng.annotations.Test; import com.google.common.base.Function; import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Maps; /** * @author Adrian Cole @@ -54,4 +60,30 @@ public class Maps2Test { }), ImmutableMap.of("foo", "bar")); } + public void testFromKeysEmptyKeys() { + assertTrue(Maps2.fromKeys(ImmutableSet.of(), identity()).isEmpty(), + "Expected returned map to be empty"); + } + + @Test(expectedExceptions = { NullPointerException.class }) + public void testFromKeysNullKey() { + Maps2.fromKeys(newHashSet((Object) null), constant("const")); + } + + public void testFromKeys() { + // ImmutableMap doesn't support null values + Map expected = Maps.newHashMap(); + expected.put("foo", "foo"); + expected.put("bar", "foo"); + expected.put("baz", null); + + assertEquals(Maps2.fromKeys(ImmutableSet.of("foo", "bar", "baz"), + new Function() { + @Override + public String apply(String input) { + return (input.equals("baz") ? null : "foo"); + } + }), expected); + } + } From 4f09edec739f57bfcddb48f4a76ded2cdcf01762 Mon Sep 17 00:00:00 2001 From: Andrew Phillips Date: Thu, 7 Jul 2011 21:36:29 -0400 Subject: [PATCH 111/264] Removed ImmutableHttpCommand that had previously been inlined in HttpRequestTask --- .../config/util/ImmutableHttpCommand.java | 73 ------------------- 1 file changed, 73 deletions(-) delete mode 100644 demos/tweetstore/runatcloud-tweetstore/src/main/java/org/jclouds/demo/tweetstore/config/util/ImmutableHttpCommand.java diff --git a/demos/tweetstore/runatcloud-tweetstore/src/main/java/org/jclouds/demo/tweetstore/config/util/ImmutableHttpCommand.java b/demos/tweetstore/runatcloud-tweetstore/src/main/java/org/jclouds/demo/tweetstore/config/util/ImmutableHttpCommand.java deleted file mode 100644 index be39628035..0000000000 --- a/demos/tweetstore/runatcloud-tweetstore/src/main/java/org/jclouds/demo/tweetstore/config/util/ImmutableHttpCommand.java +++ /dev/null @@ -1,73 +0,0 @@ -/** - * - * Copyright (C) 2011 Cloud Conscious, LLC. - * - * ==================================================================== - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ==================================================================== - */ -package org.jclouds.demo.tweetstore.config.util; - -import org.jclouds.http.HttpCommand; -import org.jclouds.http.HttpRequest; - -class ImmutableHttpCommand implements HttpCommand { - private final HttpRequest request; - - public ImmutableHttpCommand(HttpRequest request) { - this.request = request; - } - - @Override - public void setException(Exception exception) { - } - - @Override - public void setCurrentRequest(HttpRequest request) { - } - - @Override - public boolean isReplayable() { - return false; - } - - @Override - public int incrementRedirectCount() { - return 0; - } - - @Override - public int incrementFailureCount() { - return 0; - } - - @Override - public int getRedirectCount() { - return 0; - } - - @Override - public int getFailureCount() { - return 0; - } - - @Override - public Exception getException() { - return null; - } - - @Override - public HttpRequest getCurrentRequest() { - return request; - } -} \ No newline at end of file From 0b7bcb7b3fd04a475edc0ed59df90a95891eb14f Mon Sep 17 00:00:00 2001 From: Andrew Phillips Date: Thu, 7 Jul 2011 21:44:34 -0400 Subject: [PATCH 112/264] Removed the default for 'jclouds.tweetstore.blobstores' which would not work in any case if the required credential properties were not available --- .../demo/tweetstore/integration/TweetStoreLiveTest.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/demos/tweetstore/runatcloud-tweetstore/src/test/java/org/jclouds/demo/tweetstore/integration/TweetStoreLiveTest.java b/demos/tweetstore/runatcloud-tweetstore/src/test/java/org/jclouds/demo/tweetstore/integration/TweetStoreLiveTest.java index 1066dc4138..f6fd9cb4ed 100644 --- a/demos/tweetstore/runatcloud-tweetstore/src/test/java/org/jclouds/demo/tweetstore/integration/TweetStoreLiveTest.java +++ b/demos/tweetstore/runatcloud-tweetstore/src/test/java/org/jclouds/demo/tweetstore/integration/TweetStoreLiveTest.java @@ -77,8 +77,7 @@ public class TweetStoreLiveTest { private Map contexts; private String container; private static final Iterable blobstores = - Splitter.on(',').split(System.getProperty(PROPERTY_TWEETSTORE_BLOBSTORES, - "cloudfiles-us,aws-s3,azureblob")); + Splitter.on(',').split(getRequiredSystemProperty(PROPERTY_TWEETSTORE_BLOBSTORES)); private static final Properties props = new Properties(); @BeforeTest From 741920278b3cf371233f1fd5199118f07da40c59 Mon Sep 17 00:00:00 2001 From: Andrew Phillips Date: Thu, 7 Jul 2011 21:46:35 -0400 Subject: [PATCH 113/264] Now determining the list of blobstores based on the available identity/credential property pairs, with optional override via the 'jclouds.tweetstore.blobstores' system property --- .../tweetstore/config/GuiceServletConfig.java | 22 ++- .../config/util/CredentialsCollector.java | 153 ++++++++++++++++++ .../config/util/CredentialsCollectorTest.java | 82 ++++++++++ .../integration/TweetStoreLiveTest.java | 3 - 4 files changed, 253 insertions(+), 7 deletions(-) create mode 100644 demos/tweetstore/runatcloud-tweetstore/src/main/java/org/jclouds/demo/tweetstore/config/util/CredentialsCollector.java create mode 100644 demos/tweetstore/runatcloud-tweetstore/src/test/java/org/jclouds/demo/tweetstore/config/util/CredentialsCollectorTest.java diff --git a/demos/tweetstore/runatcloud-tweetstore/src/main/java/org/jclouds/demo/tweetstore/config/GuiceServletConfig.java b/demos/tweetstore/runatcloud-tweetstore/src/main/java/org/jclouds/demo/tweetstore/config/GuiceServletConfig.java index dc63e94f62..3447fd210d 100644 --- a/demos/tweetstore/runatcloud-tweetstore/src/main/java/org/jclouds/demo/tweetstore/config/GuiceServletConfig.java +++ b/demos/tweetstore/runatcloud-tweetstore/src/main/java/org/jclouds/demo/tweetstore/config/GuiceServletConfig.java @@ -19,7 +19,12 @@ package org.jclouds.demo.tweetstore.config; import static com.google.common.base.Preconditions.checkNotNull; +import static com.google.common.base.Preconditions.checkState; +import static com.google.common.base.Predicates.in; +import static com.google.common.collect.ImmutableSet.copyOf; +import static com.google.common.collect.Sets.filter; import static java.util.concurrent.TimeUnit.MINUTES; +import static org.jclouds.demo.tweetstore.reference.TweetStoreConstants.PROPERTY_TWEETSTORE_BLOBSTORES; import static org.jclouds.demo.tweetstore.reference.TweetStoreConstants.PROPERTY_TWEETSTORE_CONTAINER; import static org.jclouds.demo.tweetstore.reference.TwitterConstants.PROPERTY_TWITTER_ACCESSTOKEN; import static org.jclouds.demo.tweetstore.reference.TwitterConstants.PROPERTY_TWITTER_ACCESSTOKEN_SECRET; @@ -38,9 +43,10 @@ import javax.servlet.ServletContextEvent; import org.jclouds.blobstore.BlobStoreContext; import org.jclouds.blobstore.BlobStoreContextFactory; +import org.jclouds.demo.tweetstore.config.util.CredentialsCollector; import org.jclouds.demo.tweetstore.config.util.HttpRequestTask; -import org.jclouds.demo.tweetstore.config.util.TaskQueue; import org.jclouds.demo.tweetstore.config.util.HttpRequestTask.Factory; +import org.jclouds.demo.tweetstore.config.util.TaskQueue; import org.jclouds.demo.tweetstore.controller.AddTweetsController; import org.jclouds.demo.tweetstore.controller.StoreTweetsController; import org.jclouds.http.HttpRequest; @@ -69,8 +75,6 @@ import com.google.inject.servlet.ServletModule; * @author Adrian Cole */ public class GuiceServletConfig extends GuiceServletContextListener { - public static final String PROPERTY_BLOBSTORE_CONTEXTS = "blobstore.contexts"; - private Map providerTypeToBlobStoreMap; private Twitter twitterClient; private String container; @@ -100,7 +104,7 @@ public class GuiceServletConfig extends GuiceServletContextListener { // instantiate and store references to all blobstores by provider name providerTypeToBlobStoreMap = Maps.newHashMap(); - for (String hint : Splitter.on(',').split(checkNotNull(props.getProperty(PROPERTY_BLOBSTORE_CONTEXTS), PROPERTY_BLOBSTORE_CONTEXTS))) { + for (String hint : getBlobstoreContexts(props)) { providerTypeToBlobStoreMap.put(hint, blobStoreContextFactory.createContext(hint, modules, props)); } @@ -118,6 +122,16 @@ public class GuiceServletConfig extends GuiceServletContextListener { super.contextInitialized(servletContextEvent); } + private static Iterable getBlobstoreContexts(Properties props) { + Set contexts = new CredentialsCollector().apply(props).keySet(); + String explicitContexts = props.getProperty(PROPERTY_TWEETSTORE_BLOBSTORES); + if (explicitContexts != null) { + contexts = filter(contexts, in(copyOf(Splitter.on(',').split(explicitContexts)))); + } + checkState(!contexts.isEmpty(), "no credentials available for any requested context"); + return contexts; + } + private static URI withUrl(ServletContext servletContext, String url) { return URI.create("http://" + checkNotNull(servletContext.getInitParameter("application.host"), "application.host") + servletContext.getContextPath() + url); diff --git a/demos/tweetstore/runatcloud-tweetstore/src/main/java/org/jclouds/demo/tweetstore/config/util/CredentialsCollector.java b/demos/tweetstore/runatcloud-tweetstore/src/main/java/org/jclouds/demo/tweetstore/config/util/CredentialsCollector.java new file mode 100644 index 0000000000..6a2ea3de2b --- /dev/null +++ b/demos/tweetstore/runatcloud-tweetstore/src/main/java/org/jclouds/demo/tweetstore/config/util/CredentialsCollector.java @@ -0,0 +1,153 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.jclouds.demo.tweetstore.config.util; + +import static com.google.common.base.Preconditions.checkNotNull; +import static com.google.common.base.Preconditions.checkState; +import static com.google.common.base.Predicates.notNull; +import static com.google.common.collect.Collections2.filter; +import static com.google.common.collect.Collections2.transform; +import static com.google.common.collect.ImmutableSet.copyOf; +import static com.google.common.collect.Maps.filterValues; +import static org.jclouds.util.Maps2.fromKeys; + +import java.util.Collection; +import java.util.Map; +import java.util.Properties; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import org.jclouds.demo.tweetstore.config.util.CredentialsCollector.Credential; + +import com.google.common.annotations.GwtIncompatible; +import com.google.common.base.Function; +import com.google.common.base.Predicate; + +/** + * Reads provider credentials from a {@link Properties} bag. + * + * @author Andrew Phillips + * + */ +public class CredentialsCollector implements Function> { + private static final String IDENTITY_PROPERTY_SUFFIX = ".identity"; + private static final String CREDENTIAL_PROPERTY_SUFFIX = ".credential"; + + // using the identity for provider name extraction + private static final Pattern IDENTITY_PROPERTY_PATTERN = + Pattern.compile("([a-zA-Z0-9-]+)" + Pattern.quote(IDENTITY_PROPERTY_SUFFIX)); + + @Override + public Map apply(final Properties properties) { + Collection providerNames = transform( + filter(properties.stringPropertyNames(), MatchesPattern.matches(IDENTITY_PROPERTY_PATTERN)), + new Function() { + @Override + public String apply(String input) { + Matcher matcher = IDENTITY_PROPERTY_PATTERN.matcher(input); + // as a side-effect, sets the matching group! + checkState(matcher.matches(), "'%s' should match '%s'", input, IDENTITY_PROPERTY_PATTERN); + return matcher.group(1); + } + }); + /* + * Providers without a credential property result in null values, which are + * removed from the returned map. + */ + return filterValues(fromKeys(copyOf(providerNames), new Function() { + @Override + public Credential apply(String providerName) { + String identity = properties.getProperty(providerName + IDENTITY_PROPERTY_SUFFIX); + String credential = properties.getProperty(providerName + CREDENTIAL_PROPERTY_SUFFIX); + return (((identity != null) && (credential != null)) + ? new Credential(identity, credential) + : null); + } + }), notNull()); + } + + public static class Credential { + private final String identity; + private final String credential; + + public Credential(String identity, String credential) { + this.identity = checkNotNull(identity, "identity"); + this.credential = checkNotNull(credential, "credential"); + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + + ((credential == null) ? 0 : credential.hashCode()); + result = prime * result + + ((identity == null) ? 0 : identity.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + Credential other = (Credential) obj; + if (credential == null) { + if (other.credential != null) + return false; + } else if (!credential.equals(other.credential)) + return false; + if (identity == null) { + if (other.identity != null) + return false; + } else if (!identity.equals(other.identity)) + return false; + return true; + } + + public String getIdentity() { + return identity; + } + + public String getCredential() { + return credential; + } + } + + @GwtIncompatible(value = "java.util.regex.Pattern") + private static class MatchesPattern implements Predicate { + private final Pattern pattern; + + private MatchesPattern(Pattern pattern) { + this.pattern = pattern; + } + + @Override + public boolean apply(String input) { + return pattern.matcher(input).matches(); + } + + private static MatchesPattern matches(Pattern pattern) { + return new MatchesPattern(pattern); + } + } +} diff --git a/demos/tweetstore/runatcloud-tweetstore/src/test/java/org/jclouds/demo/tweetstore/config/util/CredentialsCollectorTest.java b/demos/tweetstore/runatcloud-tweetstore/src/test/java/org/jclouds/demo/tweetstore/config/util/CredentialsCollectorTest.java new file mode 100644 index 0000000000..128ea9e647 --- /dev/null +++ b/demos/tweetstore/runatcloud-tweetstore/src/test/java/org/jclouds/demo/tweetstore/config/util/CredentialsCollectorTest.java @@ -0,0 +1,82 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.jclouds.demo.tweetstore.config.util; + +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertTrue; + +import java.util.Map; +import java.util.Properties; + +import org.jclouds.demo.tweetstore.config.util.CredentialsCollector; +import org.jclouds.demo.tweetstore.config.util.CredentialsCollector.Credential; +import org.testng.annotations.Test; + +import com.google.common.collect.ImmutableMap; + +/** + * Tests behavior of {@code CredentialsCollector} + * + * @author Andrew Phillips + */ +@Test(groups = "unit") +public class CredentialsCollectorTest { + private CredentialsCollector collector = new CredentialsCollector(); + + public void testEmptyProperties() { + assertTrue(collector.apply(new Properties()).isEmpty(), + "Expected returned map to be empty"); + } + + public void testNoCredentials() { + Properties properties = propertiesOf(ImmutableMap.of("not-an-identity", + "v1", "not-a-credential", "v2")); + assertTrue(collector.apply(properties).isEmpty(), + "Expected returned map to be empty"); + } + + private static Properties propertiesOf(Map entries) { + Properties properties = new Properties(); + properties.putAll(entries); + return properties; + } + + public void testNonMatchingCredentials() { + Properties properties = propertiesOf(ImmutableMap.of("non_matching.identity", "v1", + "non_matching.credential", "v2")); + assertTrue(collector.apply(properties).isEmpty(), + "Expected returned map to be empty"); + } + + public void testIncompleteCredentials() { + Properties properties = propertiesOf(ImmutableMap.of("acme.identity", "v1", + "acme-2.credential", "v2")); + assertTrue(collector.apply(properties).isEmpty(), + "Expected returned map to be empty"); + } + + public void testCredentials() { + Properties properties = propertiesOf(ImmutableMap.of("acme.identity", "v1", + "acme.credential", "v2", "acme-2.identity", "v3", + "acme-2.credential", "v4")); + assertEquals(collector.apply(properties), + ImmutableMap.of("acme", new Credential("v1", "v2"), + "acme-2", new Credential("v3", "v4"))); + } +} \ No newline at end of file diff --git a/demos/tweetstore/runatcloud-tweetstore/src/test/java/org/jclouds/demo/tweetstore/integration/TweetStoreLiveTest.java b/demos/tweetstore/runatcloud-tweetstore/src/test/java/org/jclouds/demo/tweetstore/integration/TweetStoreLiveTest.java index f6fd9cb4ed..3b2647c954 100644 --- a/demos/tweetstore/runatcloud-tweetstore/src/test/java/org/jclouds/demo/tweetstore/integration/TweetStoreLiveTest.java +++ b/demos/tweetstore/runatcloud-tweetstore/src/test/java/org/jclouds/demo/tweetstore/integration/TweetStoreLiveTest.java @@ -40,7 +40,6 @@ import java.util.concurrent.TimeoutException; import org.jclouds.blobstore.BlobStoreContext; import org.jclouds.blobstore.BlobStoreContextFactory; -import org.jclouds.demo.tweetstore.config.GuiceServletConfig; import org.jclouds.demo.tweetstore.controller.StoreTweetsController; import org.jclouds.logging.log4j.config.Log4JLoggingModule; import org.jclouds.rest.AuthorizationException; @@ -57,7 +56,6 @@ import twitter4j.TwitterFactory; import twitter4j.conf.Configuration; import twitter4j.conf.ConfigurationBuilder; -import com.google.common.base.Joiner; import com.google.common.base.Splitter; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Maps; @@ -86,7 +84,6 @@ public class TweetStoreLiveTest { container = getRequiredSystemProperty(PROPERTY_TWEETSTORE_CONTAINER); props.setProperty(PROPERTY_TWEETSTORE_CONTAINER, container); - props.setProperty(GuiceServletConfig.PROPERTY_BLOBSTORE_CONTEXTS, Joiner.on(',').join(blobstores)); // put all identity/credential pairs into the client addCredentialsForBlobStores(props); From f1e93cb0f35598d522c5b165d455c4637c75cddf Mon Sep 17 00:00:00 2001 From: Andrew Phillips Date: Thu, 7 Jul 2011 21:50:27 -0400 Subject: [PATCH 114/264] Moved GAE-like TaskQueue from org.jclouds.demo.tweetstore.config.util to org.jclouds.demo.tweetstore.taskqueue --- .../jclouds/demo/tweetstore/config/GuiceServletConfig.java | 6 +++--- .../{config/util => taskqueue}/HttpRequestTask.java | 2 +- .../tweetstore/{config/util => taskqueue}/TaskQueue.java | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) rename demos/tweetstore/runatcloud-tweetstore/src/main/java/org/jclouds/demo/tweetstore/{config/util => taskqueue}/HttpRequestTask.java (99%) rename demos/tweetstore/runatcloud-tweetstore/src/main/java/org/jclouds/demo/tweetstore/{config/util => taskqueue}/TaskQueue.java (98%) diff --git a/demos/tweetstore/runatcloud-tweetstore/src/main/java/org/jclouds/demo/tweetstore/config/GuiceServletConfig.java b/demos/tweetstore/runatcloud-tweetstore/src/main/java/org/jclouds/demo/tweetstore/config/GuiceServletConfig.java index 3447fd210d..a7b49fca74 100644 --- a/demos/tweetstore/runatcloud-tweetstore/src/main/java/org/jclouds/demo/tweetstore/config/GuiceServletConfig.java +++ b/demos/tweetstore/runatcloud-tweetstore/src/main/java/org/jclouds/demo/tweetstore/config/GuiceServletConfig.java @@ -44,11 +44,11 @@ import javax.servlet.ServletContextEvent; import org.jclouds.blobstore.BlobStoreContext; import org.jclouds.blobstore.BlobStoreContextFactory; import org.jclouds.demo.tweetstore.config.util.CredentialsCollector; -import org.jclouds.demo.tweetstore.config.util.HttpRequestTask; -import org.jclouds.demo.tweetstore.config.util.HttpRequestTask.Factory; -import org.jclouds.demo.tweetstore.config.util.TaskQueue; import org.jclouds.demo.tweetstore.controller.AddTweetsController; import org.jclouds.demo.tweetstore.controller.StoreTweetsController; +import org.jclouds.demo.tweetstore.taskqueue.HttpRequestTask; +import org.jclouds.demo.tweetstore.taskqueue.TaskQueue; +import org.jclouds.demo.tweetstore.taskqueue.HttpRequestTask.Factory; import org.jclouds.http.HttpRequest; import twitter4j.Twitter; diff --git a/demos/tweetstore/runatcloud-tweetstore/src/main/java/org/jclouds/demo/tweetstore/config/util/HttpRequestTask.java b/demos/tweetstore/runatcloud-tweetstore/src/main/java/org/jclouds/demo/tweetstore/taskqueue/HttpRequestTask.java similarity index 99% rename from demos/tweetstore/runatcloud-tweetstore/src/main/java/org/jclouds/demo/tweetstore/config/util/HttpRequestTask.java rename to demos/tweetstore/runatcloud-tweetstore/src/main/java/org/jclouds/demo/tweetstore/taskqueue/HttpRequestTask.java index a05314d765..c3ad50f17e 100644 --- a/demos/tweetstore/runatcloud-tweetstore/src/main/java/org/jclouds/demo/tweetstore/config/util/HttpRequestTask.java +++ b/demos/tweetstore/runatcloud-tweetstore/src/main/java/org/jclouds/demo/tweetstore/taskqueue/HttpRequestTask.java @@ -16,7 +16,7 @@ * limitations under the License. * ==================================================================== */ -package org.jclouds.demo.tweetstore.config.util; +package org.jclouds.demo.tweetstore.taskqueue; import static com.google.common.base.Preconditions.checkNotNull; import static com.google.inject.name.Names.bindProperties; diff --git a/demos/tweetstore/runatcloud-tweetstore/src/main/java/org/jclouds/demo/tweetstore/config/util/TaskQueue.java b/demos/tweetstore/runatcloud-tweetstore/src/main/java/org/jclouds/demo/tweetstore/taskqueue/TaskQueue.java similarity index 98% rename from demos/tweetstore/runatcloud-tweetstore/src/main/java/org/jclouds/demo/tweetstore/config/util/TaskQueue.java rename to demos/tweetstore/runatcloud-tweetstore/src/main/java/org/jclouds/demo/tweetstore/taskqueue/TaskQueue.java index 664ed5ab0e..a31120bbae 100644 --- a/demos/tweetstore/runatcloud-tweetstore/src/main/java/org/jclouds/demo/tweetstore/config/util/TaskQueue.java +++ b/demos/tweetstore/runatcloud-tweetstore/src/main/java/org/jclouds/demo/tweetstore/taskqueue/TaskQueue.java @@ -16,7 +16,7 @@ * limitations under the License. * ==================================================================== */ -package org.jclouds.demo.tweetstore.config.util; +package org.jclouds.demo.tweetstore.taskqueue; import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkNotNull; From c3b92ef911a1a467ebb2c46a0fd84ab5ca282a6c Mon Sep 17 00:00:00 2001 From: Andrew Phillips Date: Thu, 7 Jul 2011 22:09:07 -0400 Subject: [PATCH 115/264] Removed an unused bit of surefire plugin configuration --- .../tweetstore/gae-tweetstore-spring/pom.xml | 37 ------------------ demos/tweetstore/gae-tweetstore/pom.xml | 36 ----------------- .../tweetstore/runatcloud-tweetstore/pom.xml | 39 +------------------ 3 files changed, 1 insertion(+), 111 deletions(-) diff --git a/demos/tweetstore/gae-tweetstore-spring/pom.xml b/demos/tweetstore/gae-tweetstore-spring/pom.xml index 985b50c87f..725a1f6882 100644 --- a/demos/tweetstore/gae-tweetstore-spring/pom.xml +++ b/demos/tweetstore/gae-tweetstore-spring/pom.xml @@ -80,43 +80,6 @@ test
    - - - - - maven-surefire-plugin - - - integration - integration-test - - test - - - - - appengine.sdk.root - ${appengine.sdk.root} - - - devappserver.address - ${devappserver.address} - - - devappserver.port - ${devappserver.port} - - - warfile - ${project.build.directory}/${project.artifactId} - - - - - - - - diff --git a/demos/tweetstore/gae-tweetstore/pom.xml b/demos/tweetstore/gae-tweetstore/pom.xml index 722b1e4150..6af9f32e01 100644 --- a/demos/tweetstore/gae-tweetstore/pom.xml +++ b/demos/tweetstore/gae-tweetstore/pom.xml @@ -67,42 +67,6 @@ test - - - - maven-surefire-plugin - - - integration - integration-test - - test - - - - - appengine.sdk.root - ${appengine.sdk.root} - - - devappserver.address - ${devappserver.address} - - - devappserver.port - ${devappserver.port} - - - warfile - ${project.build.directory}/${project.artifactId} - - - - - - - - diff --git a/demos/tweetstore/runatcloud-tweetstore/pom.xml b/demos/tweetstore/runatcloud-tweetstore/pom.xml index 6839f72f53..803a207532 100644 --- a/demos/tweetstore/runatcloud-tweetstore/pom.xml +++ b/demos/tweetstore/runatcloud-tweetstore/pom.xml @@ -60,44 +60,7 @@ test - - - - - maven-surefire-plugin - - - integration - integration-test - - test - - - - - bees.address - ${test.bees.address} - - - bees.port - ${test.bees.port} - - - bees.basedir - ${project.build.directory}/bees - - - warfile - ${project.build.directory}/${project.artifactId} - - - - - - - - - + From 73117e366235566847ccc086c9dc27dbe0d7cb7a Mon Sep 17 00:00:00 2001 From: Andrew Phillips Date: Thu, 7 Jul 2011 22:35:09 -0400 Subject: [PATCH 116/264] Updated KickStart args and integration test setup --- demos/googleappengine/pom.xml | 83 +++++-------------- .../functest/GoogleAppEngineLiveTest.java | 2 +- .../functest/GoogleDevServer.java | 35 +++++--- 3 files changed, 45 insertions(+), 75 deletions(-) diff --git a/demos/googleappengine/pom.xml b/demos/googleappengine/pom.xml index beccf05e6b..e9e7453a6e 100644 --- a/demos/googleappengine/pom.xml +++ b/demos/googleappengine/pom.xml @@ -25,7 +25,7 @@ org.jclouds jclouds-demos-project - 1.0-SNAPSHOT + 1.1.0-SNAPSHOT jclouds-demo-googleappengine war @@ -34,9 +34,9 @@ jclouds-aws-demo + 1.4.2 localhost 8088 - @@ -54,11 +54,13 @@ org.jclouds.provider aws-s3 ${project.version} + runtime org.jclouds.provider aws-ec2 ${project.version} + runtime org.jclouds.driver @@ -74,6 +76,7 @@ displaytag displaytag 1.2 + runtime org.slf4j @@ -85,6 +88,7 @@ org.slf4j slf4j-jdk14 1.5.6 + runtime standard @@ -96,39 +100,31 @@ jstl javax.servlet 1.1.2 + runtime - org.apache.geronimo.specs - geronimo-el_1.0_spec - 1.0.1 - - - org.apache.geronimo.specs - geronimo-jsp_2.1_spec - 1.0.1 - provided - - - org.apache.geronimo.specs - geronimo-servlet_2.5_spec - 1.2 + javax.servlet + servlet-api + 2.5 provided + com.google.appengine appengine-tools-sdk - 1.4.3 - system - ${appengine.home}/lib/appengine-tools-api.jar + ${appengine.sdk.version} + test ${project.artifactId} - org.apache.maven.plugins maven-war-plugin + 2.1.1 + + WEB-INF/web.xml src/main/appengine @@ -138,44 +134,6 @@ - - org.apache.maven.plugins - maven-surefire-plugin - - - integration - integration-test - - test - - - - - devappserver.address - ${devappserver.address} - - - devappserver.port - ${devappserver.port} - - - warfile - ${project.build.directory}/${project.artifactId} - - - - ${env.APPENGINE_HOME}/lib/appengine-tools-api.jar - - - true - ${env.APPENGINE_HOME}/bin - ${env.APPENGINE_HOME}/lib - ${env.APPENGINE_HOME}/config/sdk - - - - - @@ -185,7 +143,6 @@ - org.apache.maven.plugins maven-surefire-plugin @@ -198,15 +155,17 @@ test.aws.identity - ${test.aws.identity} + + ${test.aws-s3.identity} test.aws.credential - ${test.aws.credential} + + ${test.aws-s3.credential} appengine.sdk.root - ${env.APPENGINE_HOME} + ${appengine.sdk.root} devappserver.address diff --git a/demos/googleappengine/src/test/java/org/jclouds/samples/googleappengine/functest/GoogleAppEngineLiveTest.java b/demos/googleappengine/src/test/java/org/jclouds/samples/googleappengine/functest/GoogleAppEngineLiveTest.java index e1007ef4fc..9b9f7e9b85 100644 --- a/demos/googleappengine/src/test/java/org/jclouds/samples/googleappengine/functest/GoogleAppEngineLiveTest.java +++ b/demos/googleappengine/src/test/java/org/jclouds/samples/googleappengine/functest/GoogleAppEngineLiveTest.java @@ -36,7 +36,7 @@ import org.testng.annotations.Test; * * @author Adrian Cole */ -@Test(groups = "live", sequential = true) +@Test(groups = "live", singleThreaded = true) public class GoogleAppEngineLiveTest { GoogleDevServer server; diff --git a/demos/googleappengine/src/test/java/org/jclouds/samples/googleappengine/functest/GoogleDevServer.java b/demos/googleappengine/src/test/java/org/jclouds/samples/googleappengine/functest/GoogleDevServer.java index b74d9d2e49..ad6c9e92c2 100644 --- a/demos/googleappengine/src/test/java/org/jclouds/samples/googleappengine/functest/GoogleDevServer.java +++ b/demos/googleappengine/src/test/java/org/jclouds/samples/googleappengine/functest/GoogleDevServer.java @@ -18,16 +18,21 @@ */ package org.jclouds.samples.googleappengine.functest; +import static com.google.common.base.Preconditions.checkNotNull; +import static java.lang.String.format; + import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.util.Properties; +import java.util.concurrent.TimeUnit; import com.google.appengine.tools.KickStart; +import com.google.appengine.tools.info.SdkInfo; /** * Basic functionality to start a local google app engine instance. - * + * * @author Adrian Cole */ public class GoogleDevServer { @@ -35,26 +40,27 @@ public class GoogleDevServer { Thread server; public void writePropertiesAndStartServer(final String address, - final String port, final String warfile, Properties props) + final String port, final String warfile, Properties props) throws IOException, InterruptedException { - String filename = String.format( - "%1$s/WEB-INF/jclouds.properties", warfile); + String filename = String.format("%1$s/WEB-INF/jclouds.properties", warfile); System.err.println("file: " + filename); props.store(new FileOutputStream(filename), "test"); assert new File(filename).exists(); this.server = new Thread(new Runnable() { public void run() { - KickStart - .main(new String[]{ - "com.google.appengine.tools.development.DevAppServerMain", - "--disable_update_check", "-a", address, "-p", - port, warfile}); - + String sdkRoot = checkNotNull(System.getProperty(SdkInfo.SDK_ROOT_PROPERTY), SdkInfo.SDK_ROOT_PROPERTY); + KickStart.main(new String[] { + KickStarter.systemProperty("java.util.logging.config.file", + format("%s/WEB-INF/logging.properties", warfile)), + KickStarter.systemProperty(SdkInfo.SDK_ROOT_PROPERTY, sdkRoot), + "com.google.appengine.tools.development.DevAppServerMain", + "--disable_update_check", + format("--sdk_root=%s", sdkRoot), + "-a", address, "-p", port, warfile }); } - }); server.start(); - Thread.sleep(30 * 1000); + TimeUnit.SECONDS.sleep(30); } public void stop() throws Exception { @@ -62,4 +68,9 @@ public class GoogleDevServer { server.interrupt(); } + private static class KickStarter { + private static String systemProperty(String key, String value) { + return format("--jvm_flag=-D%s=%s", key, value); + } + } } \ No newline at end of file From b037be29fa892475f8cc760fc41f1c01075cd5c6 Mon Sep 17 00:00:00 2001 From: Adrian Cole Date: Thu, 7 Jul 2011 17:29:20 -0700 Subject: [PATCH 117/264] updated rackspace default version to ubuntu 11.04 --- .../compute/CloudServersUKTemplateBuilderLiveTest.java | 2 +- .../compute/CloudServersUSTemplateBuilderLiveTest.java | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/providers/cloudservers-uk/src/test/java/org/jclouds/rackspace/cloudservers/compute/CloudServersUKTemplateBuilderLiveTest.java b/providers/cloudservers-uk/src/test/java/org/jclouds/rackspace/cloudservers/compute/CloudServersUKTemplateBuilderLiveTest.java index bc3a960105..a0ac2f444c 100644 --- a/providers/cloudservers-uk/src/test/java/org/jclouds/rackspace/cloudservers/compute/CloudServersUKTemplateBuilderLiveTest.java +++ b/providers/cloudservers-uk/src/test/java/org/jclouds/rackspace/cloudservers/compute/CloudServersUKTemplateBuilderLiveTest.java @@ -52,7 +52,7 @@ public class CloudServersUKTemplateBuilderLiveTest extends BaseTemplateBuilderLi public boolean apply(OsFamilyVersion64Bit input) { switch (input.family) { case UBUNTU: - return !(input.version.startsWith("11") || input.version.equals("8.04")) && input.is64Bit; + return !(input.version.startsWith("11.10") || input.version.equals("8.04")) && input.is64Bit; case DEBIAN: return input.is64Bit; case CENTOS: diff --git a/providers/cloudservers-us/src/test/java/org/jclouds/rackspace/cloudservers/compute/CloudServersUSTemplateBuilderLiveTest.java b/providers/cloudservers-us/src/test/java/org/jclouds/rackspace/cloudservers/compute/CloudServersUSTemplateBuilderLiveTest.java index 14659b8cef..2f1bcf9096 100644 --- a/providers/cloudservers-us/src/test/java/org/jclouds/rackspace/cloudservers/compute/CloudServersUSTemplateBuilderLiveTest.java +++ b/providers/cloudservers-us/src/test/java/org/jclouds/rackspace/cloudservers/compute/CloudServersUSTemplateBuilderLiveTest.java @@ -52,7 +52,7 @@ public class CloudServersUSTemplateBuilderLiveTest extends BaseTemplateBuilderLi public boolean apply(OsFamilyVersion64Bit input) { switch (input.family) { case UBUNTU: - return !(input.version.startsWith("11") || input.version.equals("8.04")) && input.is64Bit; + return !(input.version.startsWith("11.10") || input.version.equals("8.04")) && input.is64Bit; case DEBIAN: return input.is64Bit; case CENTOS: @@ -72,7 +72,7 @@ public class CloudServersUSTemplateBuilderLiveTest extends BaseTemplateBuilderLi public void testTemplateBuilder() { Template defaultTemplate = this.context.getComputeService().templateBuilder().build(); assertEquals(defaultTemplate.getImage().getOperatingSystem().is64Bit(), true); - assertEquals(defaultTemplate.getImage().getOperatingSystem().getVersion(), "10.10"); + assertEquals(defaultTemplate.getImage().getOperatingSystem().getVersion(), "11.04"); assertEquals(defaultTemplate.getImage().getOperatingSystem().getFamily(), OsFamily.UBUNTU); assertEquals(defaultTemplate.getLocation().getId(), provider); assertEquals(getCores(defaultTemplate.getHardware()), 1.0d); From 7f1a543fb6b42ae50ad779b5645f68bf90f96039 Mon Sep 17 00:00:00 2001 From: Adrian Cole Date: Fri, 8 Jul 2011 02:05:19 -0700 Subject: [PATCH 118/264] fixed problem where empty query string doesn't work: Issue 576 --- .../org/jclouds/http/utils/ModifyRequest.java | 3 ++- .../internal/RestAnnotationProcessorTest.java | 15 +++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/core/src/main/java/org/jclouds/http/utils/ModifyRequest.java b/core/src/main/java/org/jclouds/http/utils/ModifyRequest.java index ba1c0b2860..b2b7933467 100644 --- a/core/src/main/java/org/jclouds/http/utils/ModifyRequest.java +++ b/core/src/main/java/org/jclouds/http/utils/ModifyRequest.java @@ -168,8 +168,9 @@ public class ModifyRequest { while (pairs.hasNext()) { Map.Entry pair = pairs.next(); formBuilder.append(Strings2.urlEncode(pair.getKey(), skips)); - if (pair.getValue() != null && !pair.getValue().equals("")) { + if (pair.getValue() != null) formBuilder.append("="); + if (pair.getValue() != null && !pair.getValue().equals("")) { formBuilder.append(Strings2.urlEncode(pair.getValue(), skips)); } if (pairs.hasNext()) diff --git a/core/src/test/java/org/jclouds/rest/internal/RestAnnotationProcessorTest.java b/core/src/test/java/org/jclouds/rest/internal/RestAnnotationProcessorTest.java index d94e3081d3..10fdda1062 100644 --- a/core/src/test/java/org/jclouds/rest/internal/RestAnnotationProcessorTest.java +++ b/core/src/test/java/org/jclouds/rest/internal/RestAnnotationProcessorTest.java @@ -1865,6 +1865,11 @@ public class RestAnnotationProcessorTest extends BaseRestClientTest { @QueryParams(keys = "acl") ListenableFuture getQueryNull(@PathParam("id") String id); + @GET + @Path("/{id}") + @QueryParams(keys = "acl", values="") + ListenableFuture getQueryEmpty(@PathParam("id") String id); + @PUT @Path("/{id}") ListenableFuture put(@PathParam("id") @ParamParser(FirstCharacter.class) String id, @@ -1947,6 +1952,16 @@ public class RestAnnotationProcessorTest extends BaseRestClientTest { assertEquals(request.getMethod(), HttpMethod.GET); assertEquals(request.getHeaders().size(), 0); } + + public void testCreateGetQueryEmpty() throws SecurityException, NoSuchMethodException { + Method method = TestRequest.class.getMethod("getQueryEmpty", String.class); + HttpRequest request = factory(TestRequest.class).createRequest(method, new Object[] { "1" }); + assertEquals(request.getEndpoint().getHost(), "localhost"); + assertEquals(request.getEndpoint().getPath(), "/1"); + assertEquals(request.getEndpoint().getQuery(), "acl="); + assertEquals(request.getMethod(), HttpMethod.GET); + assertEquals(request.getHeaders().size(), 0); + } public class PayloadOptions extends BaseHttpRequestOptions { @Override From b4e3bec64440e94272717af3dda7fe0d10d86776 Mon Sep 17 00:00:00 2001 From: Adrian Cole Date: Fri, 8 Jul 2011 02:06:48 -0700 Subject: [PATCH 119/264] changed builders to accept iterable as it is easier in guava than sets --- .../org/jclouds/compute/domain/ComputeMetadataBuilder.java | 2 +- .../main/java/org/jclouds/compute/domain/HardwareBuilder.java | 3 +-- .../src/main/java/org/jclouds/compute/domain/ImageBuilder.java | 3 +-- .../java/org/jclouds/compute/domain/NodeMetadataBuilder.java | 2 +- 4 files changed, 4 insertions(+), 6 deletions(-) diff --git a/compute/src/main/java/org/jclouds/compute/domain/ComputeMetadataBuilder.java b/compute/src/main/java/org/jclouds/compute/domain/ComputeMetadataBuilder.java index b6f6093d5a..fed529c119 100644 --- a/compute/src/main/java/org/jclouds/compute/domain/ComputeMetadataBuilder.java +++ b/compute/src/main/java/org/jclouds/compute/domain/ComputeMetadataBuilder.java @@ -48,7 +48,7 @@ public class ComputeMetadataBuilder extends ResourceMetadataBuilder return this; } - public ComputeMetadataBuilder tags(Set tags) { + public ComputeMetadataBuilder tags(Iterable tags) { this.tags = ImmutableSet. copyOf(checkNotNull(tags, "tags")); return this; } diff --git a/compute/src/main/java/org/jclouds/compute/domain/HardwareBuilder.java b/compute/src/main/java/org/jclouds/compute/domain/HardwareBuilder.java index caaea0035e..8e6ed84116 100644 --- a/compute/src/main/java/org/jclouds/compute/domain/HardwareBuilder.java +++ b/compute/src/main/java/org/jclouds/compute/domain/HardwareBuilder.java @@ -25,7 +25,6 @@ import static org.jclouds.compute.predicates.ImagePredicates.any; import java.net.URI; import java.util.List; import java.util.Map; -import java.util.Set; import org.jclouds.compute.domain.internal.HardwareImpl; import org.jclouds.compute.predicates.ImagePredicates; @@ -90,7 +89,7 @@ public class HardwareBuilder extends ComputeMetadataBuilder { } @Override - public HardwareBuilder tags(Set tags) { + public HardwareBuilder tags(Iterable tags) { return HardwareBuilder.class.cast(super.tags(tags)); } diff --git a/compute/src/main/java/org/jclouds/compute/domain/ImageBuilder.java b/compute/src/main/java/org/jclouds/compute/domain/ImageBuilder.java index bd99e9be02..292043adef 100644 --- a/compute/src/main/java/org/jclouds/compute/domain/ImageBuilder.java +++ b/compute/src/main/java/org/jclouds/compute/domain/ImageBuilder.java @@ -22,7 +22,6 @@ import static com.google.common.base.Preconditions.checkNotNull; import java.net.URI; import java.util.Map; -import java.util.Set; import javax.annotation.Nullable; @@ -75,7 +74,7 @@ public class ImageBuilder extends ComputeMetadataBuilder { return ImageBuilder.class.cast(super.id(id)); } - public ImageBuilder tags(Set tags) { + public ImageBuilder tags(Iterable tags) { return ImageBuilder.class.cast(super.tags(tags)); } diff --git a/compute/src/main/java/org/jclouds/compute/domain/NodeMetadataBuilder.java b/compute/src/main/java/org/jclouds/compute/domain/NodeMetadataBuilder.java index 1f0671b7ab..17cf4507cb 100644 --- a/compute/src/main/java/org/jclouds/compute/domain/NodeMetadataBuilder.java +++ b/compute/src/main/java/org/jclouds/compute/domain/NodeMetadataBuilder.java @@ -114,7 +114,7 @@ public class NodeMetadataBuilder extends ComputeMetadataBuilder { } @Override - public NodeMetadataBuilder tags(Set tags) { + public NodeMetadataBuilder tags(Iterable tags) { return NodeMetadataBuilder.class.cast(super.tags(tags)); } From c8ebbc2f022d5905c42d911f9f1ee5d34f60add3 Mon Sep 17 00:00:00 2001 From: Adrian Cole Date: Fri, 8 Jul 2011 02:07:21 -0700 Subject: [PATCH 120/264] updated cloudservers uk template settings to match current images --- .../compute/CloudServersUKTemplateBuilderLiveTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/providers/cloudservers-uk/src/test/java/org/jclouds/rackspace/cloudservers/compute/CloudServersUKTemplateBuilderLiveTest.java b/providers/cloudservers-uk/src/test/java/org/jclouds/rackspace/cloudservers/compute/CloudServersUKTemplateBuilderLiveTest.java index a0ac2f444c..56cde15148 100644 --- a/providers/cloudservers-uk/src/test/java/org/jclouds/rackspace/cloudservers/compute/CloudServersUKTemplateBuilderLiveTest.java +++ b/providers/cloudservers-uk/src/test/java/org/jclouds/rackspace/cloudservers/compute/CloudServersUKTemplateBuilderLiveTest.java @@ -72,7 +72,7 @@ public class CloudServersUKTemplateBuilderLiveTest extends BaseTemplateBuilderLi public void testTemplateBuilder() { Template defaultTemplate = this.context.getComputeService().templateBuilder().build(); assertEquals(defaultTemplate.getImage().getOperatingSystem().is64Bit(), true); - assertEquals(defaultTemplate.getImage().getOperatingSystem().getVersion(), "10.10"); + assertEquals(defaultTemplate.getImage().getOperatingSystem().getVersion(), "11.04"); assertEquals(defaultTemplate.getImage().getOperatingSystem().getFamily(), OsFamily.UBUNTU); assertEquals(defaultTemplate.getLocation().getId(), provider); assertEquals(getCores(defaultTemplate.getHardware()), 1.0d); From 537691226e93d6fbb1726857f1077c3a9ee8e3a2 Mon Sep 17 00:00:00 2001 From: Adrian Cole Date: Fri, 8 Jul 2011 02:09:36 -0700 Subject: [PATCH 121/264] added hypervisor property to ec2 image --- .../ec2/compute/functions/EC2ImageParser.java | 5 +- .../org/jclouds/ec2/domain/Hypervisor.java | 51 +++++++++++++++++++ .../java/org/jclouds/ec2/domain/Image.java | 17 ++++++- .../xml/DescribeImagesResponseHandler.java | 7 ++- .../compute/functions/EC2ImageParserTest.java | 6 +-- .../DescribeImagesResponseHandlerTest.java | 8 +-- .../strategy/AWSEC2ImageParserTest.java | 4 +- ...ptusPartnerCloudReviseParsedImageTest.java | 11 ++-- 8 files changed, 92 insertions(+), 17 deletions(-) create mode 100644 apis/ec2/src/main/java/org/jclouds/ec2/domain/Hypervisor.java diff --git a/apis/ec2/src/main/java/org/jclouds/ec2/compute/functions/EC2ImageParser.java b/apis/ec2/src/main/java/org/jclouds/ec2/compute/functions/EC2ImageParser.java index 55a23af62a..1e4b4b213b 100644 --- a/apis/ec2/src/main/java/org/jclouds/ec2/compute/functions/EC2ImageParser.java +++ b/apis/ec2/src/main/java/org/jclouds/ec2/compute/functions/EC2ImageParser.java @@ -87,8 +87,9 @@ public class EC2ImageParser implements Function of("owner", from.getImageOwnerId(), "rootDeviceType", from - .getRootDeviceType().toString())); + builder.userMetadata(ImmutableMap. builder().put("owner", from.getImageOwnerId()).put( + "rootDeviceType", from.getRootDeviceType().value()).put("virtualizationType", + from.getVirtualizationType().value()).put("hypervisor", from.getHypervisor().value()).build()); OperatingSystem.Builder osBuilder = OperatingSystem.builder(); osBuilder.is64Bit(from.getArchitecture() == Architecture.X86_64); diff --git a/apis/ec2/src/main/java/org/jclouds/ec2/domain/Hypervisor.java b/apis/ec2/src/main/java/org/jclouds/ec2/domain/Hypervisor.java new file mode 100644 index 0000000000..b067e99a6f --- /dev/null +++ b/apis/ec2/src/main/java/org/jclouds/ec2/domain/Hypervisor.java @@ -0,0 +1,51 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.jclouds.ec2.domain; + +import com.google.common.base.CaseFormat; + +/** + * Hypervisor of the image. + * + * @author Adrian Cole + */ +public enum Hypervisor { + + XEN, + /** + * Oracle VM Server + */ + OVM, UNRECOGNIZED; + + public String value() { + return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.LOWER_HYPHEN, name()); + } + + public String toString() { + return value(); + } + + public static Hypervisor fromValue(String v) { + try { + return valueOf(CaseFormat.LOWER_HYPHEN.to(CaseFormat.UPPER_UNDERSCORE, v)); + } catch (IllegalArgumentException e) { + return UNRECOGNIZED; + } + } +} diff --git a/apis/ec2/src/main/java/org/jclouds/ec2/domain/Image.java b/apis/ec2/src/main/java/org/jclouds/ec2/domain/Image.java index 66cb20ccb4..d5e83a7542 100644 --- a/apis/ec2/src/main/java/org/jclouds/ec2/domain/Image.java +++ b/apis/ec2/src/main/java/org/jclouds/ec2/domain/Image.java @@ -66,11 +66,17 @@ public class Image implements Comparable { return virtualizationType; } + private final Hypervisor hypervisor; + + public Hypervisor getHypervisor() { + return hypervisor; + } + public Image(String region, Architecture architecture, @Nullable String name, @Nullable String description, String imageId, String imageLocation, String imageOwnerId, ImageState imageState, ImageType imageType, boolean isPublic, Iterable productCodes, @Nullable String kernelId, @Nullable String platform, @Nullable String ramdiskId, RootDeviceType rootDeviceType, @Nullable String rootDeviceName, - Map ebsBlockDevices, VirtualizationType virtualizationType) { + Map ebsBlockDevices, VirtualizationType virtualizationType, Hypervisor hypervisor) { this.region = checkNotNull(region, "region"); this.architecture = checkNotNull(architecture, "architecture"); this.imageId = checkNotNull(imageId, "imageId"); @@ -89,6 +95,7 @@ public class Image implements Comparable { this.rootDeviceType = checkNotNull(rootDeviceType, "rootDeviceType"); this.ebsBlockDevices.putAll(checkNotNull(ebsBlockDevices, "ebsBlockDevices")); this.virtualizationType = checkNotNull(virtualizationType, "virtualizationType"); + this.hypervisor = checkNotNull(hypervisor, "hypervisor"); } /** The serialVersionUID */ @@ -353,6 +360,7 @@ public class Image implements Comparable { result = prime * result + ((rootDeviceName == null) ? 0 : rootDeviceName.hashCode()); result = prime * result + ((rootDeviceType == null) ? 0 : rootDeviceType.hashCode()); result = prime * result + ((virtualizationType == null) ? 0 : virtualizationType.hashCode()); + result = prime * result + ((hypervisor == null) ? 0 : hypervisor.hashCode()); return result; } @@ -452,6 +460,11 @@ public class Image implements Comparable { return false; } else if (!virtualizationType.equals(other.virtualizationType)) return false; + if (hypervisor == null) { + if (other.hypervisor != null) + return false; + } else if (!hypervisor.equals(other.hypervisor)) + return false; return true; } @@ -463,7 +476,7 @@ public class Image implements Comparable { + ", kernelId=" + kernelId + ", name=" + name + ", platform=" + platform + ", productCodes=" + productCodes + ", ramdiskId=" + ramdiskId + ", region=" + region + ", rootDeviceName=" + rootDeviceName + ", rootDeviceType=" + rootDeviceType + ", virtualizationType=" + virtualizationType - + "]"; + + ", hypervisor=" + hypervisor + "]"; } } diff --git a/apis/ec2/src/main/java/org/jclouds/ec2/xml/DescribeImagesResponseHandler.java b/apis/ec2/src/main/java/org/jclouds/ec2/xml/DescribeImagesResponseHandler.java index 33584f08f7..e96b555608 100644 --- a/apis/ec2/src/main/java/org/jclouds/ec2/xml/DescribeImagesResponseHandler.java +++ b/apis/ec2/src/main/java/org/jclouds/ec2/xml/DescribeImagesResponseHandler.java @@ -25,6 +25,7 @@ import javax.annotation.Resource; import javax.inject.Inject; import org.jclouds.aws.util.AWSUtils; +import org.jclouds.ec2.domain.Hypervisor; import org.jclouds.ec2.domain.Image; import org.jclouds.ec2.domain.RootDeviceType; import org.jclouds.ec2.domain.VirtualizationType; @@ -86,6 +87,7 @@ public class DescribeImagesResponseHandler extends ParseSax.HandlerForGeneratedR private String deviceName; private String snapshotId; private VirtualizationType virtualizationType = VirtualizationType.PARAVIRTUAL; + private Hypervisor hypervisor = Hypervisor.XEN; private int volumeSize; private boolean deleteOnTermination = true;// correct default is true. @@ -150,6 +152,8 @@ public class DescribeImagesResponseHandler extends ParseSax.HandlerForGeneratedR rootDeviceName = currentText.toString().trim(); } else if (qName.equals("virtualizationType")) { virtualizationType = VirtualizationType.fromValue(currentText.toString().trim()); + } else if (qName.equals("hypervisor")) { + hypervisor = Hypervisor.fromValue(currentText.toString().trim()); } else if (qName.equals("item")) { if (inBlockDeviceMapping) { ebsBlockDevices.put(deviceName, new Image.EbsBlockDevice(snapshotId, volumeSize, deleteOnTermination)); @@ -164,7 +168,7 @@ public class DescribeImagesResponseHandler extends ParseSax.HandlerForGeneratedR region = defaultRegion; contents.add(new Image(region, architecture, this.name, description, imageId, imageLocation, imageOwnerId, imageState, imageType, isPublic, productCodes, kernelId, platform, ramdiskId, - rootDeviceType, rootDeviceName, ebsBlockDevices, virtualizationType)); + rootDeviceType, rootDeviceName, ebsBlockDevices, virtualizationType, hypervisor)); } catch (NullPointerException e) { logger.warn(e, "malformed image: %s", imageId); } @@ -185,6 +189,7 @@ public class DescribeImagesResponseHandler extends ParseSax.HandlerForGeneratedR this.rootDeviceName = null; this.ebsBlockDevices = Maps.newHashMap(); this.virtualizationType = VirtualizationType.PARAVIRTUAL; + this.hypervisor = Hypervisor.XEN; } } diff --git a/apis/ec2/src/test/java/org/jclouds/ec2/compute/functions/EC2ImageParserTest.java b/apis/ec2/src/test/java/org/jclouds/ec2/compute/functions/EC2ImageParserTest.java index c842506485..dcbb78e3fb 100644 --- a/apis/ec2/src/test/java/org/jclouds/ec2/compute/functions/EC2ImageParserTest.java +++ b/apis/ec2/src/test/java/org/jclouds/ec2/compute/functions/EC2ImageParserTest.java @@ -25,7 +25,7 @@ import java.util.Set; import org.jclouds.compute.config.BaseComputeServiceContextModule; import org.jclouds.compute.domain.ImageBuilder; -import org.jclouds.compute.domain.OperatingSystemBuilder; +import org.jclouds.compute.domain.OperatingSystem; import org.jclouds.compute.domain.OsFamily; import org.jclouds.compute.reference.ComputeServiceConstants; import org.jclouds.domain.Credentials; @@ -59,14 +59,14 @@ public class EC2ImageParserTest { Set result = convertImages("/amzn_images.xml"); assertEquals(Iterables.get(result, 0), new ImageBuilder().operatingSystem( - new OperatingSystemBuilder().family(OsFamily.UNRECOGNIZED).arch("paravirtual").version("").description( + new OperatingSystem.Builder().family(OsFamily.UNRECOGNIZED).arch("paravirtual").version("").description( "137112412989/amzn-ami-0.9.7-beta.i386-ebs").is64Bit(false).build()).description("Amazon") .defaultCredentials(new Credentials("ec2-user", null)).id("us-east-1/ami-82e4b5c7").providerId( "ami-82e4b5c7").location(defaultLocation).userMetadata( ImmutableMap.of("owner", "137112412989", "rootDeviceType", "ebs")).build()); assertEquals(Iterables.get(result, 3), new ImageBuilder().operatingSystem( - new OperatingSystemBuilder().family(OsFamily.UNRECOGNIZED).arch("paravirtual").version("").description( + new OperatingSystem.Builder().family(OsFamily.UNRECOGNIZED).arch("paravirtual").version("").description( "amzn-ami-us-west-1/amzn-ami-0.9.7-beta.x86_64.manifest.xml").is64Bit(true).build()) .description("Amazon Linux AMI x86_64 S3").defaultCredentials(new Credentials("ec2-user", null)).id( "us-east-1/ami-f2e4b5b7").providerId("ami-f2e4b5b7").location(defaultLocation).userMetadata( diff --git a/apis/ec2/src/test/java/org/jclouds/ec2/xml/DescribeImagesResponseHandlerTest.java b/apis/ec2/src/test/java/org/jclouds/ec2/xml/DescribeImagesResponseHandlerTest.java index f1eb11c12e..54c5332edc 100644 --- a/apis/ec2/src/test/java/org/jclouds/ec2/xml/DescribeImagesResponseHandlerTest.java +++ b/apis/ec2/src/test/java/org/jclouds/ec2/xml/DescribeImagesResponseHandlerTest.java @@ -24,6 +24,7 @@ import java.io.InputStream; import java.util.Set; import org.jclouds.ec2.compute.functions.EC2ImageParserTest; +import org.jclouds.ec2.domain.Hypervisor; import org.jclouds.ec2.domain.Image; import org.jclouds.ec2.domain.RootDeviceType; import org.jclouds.ec2.domain.VirtualizationType; @@ -56,7 +57,7 @@ public class DescribeImagesResponseHandlerTest { "ec2-public-images/fedora-8-i386-base-v1.04.manifest.xml", "206029621532", ImageState.AVAILABLE, ImageType.MACHINE, false, Sets. newHashSet("9961934F"), "aki-4438dd2d", null, "ari-4538dd2c", RootDeviceType.INSTANCE_STORE, null, ImmutableMap. of(), - VirtualizationType.PARAVIRTUAL)); + VirtualizationType.PARAVIRTUAL, Hypervisor.XEN)); Set result = parseImages("/describe_images.xml"); @@ -68,7 +69,8 @@ public class DescribeImagesResponseHandlerTest { "aws-solutions-amis/SqlSvrStd2003r2-x86_64-Win_SFWBasic5.1-v1.0.manifest.xml", "771350841976", ImageState.AVAILABLE, ImageType.MACHINE, true, Sets. newHashSet("5771E9A6"), null, "windows", null, RootDeviceType.INSTANCE_STORE, null, ImmutableMap. of(), - VirtualizationType.PARAVIRTUAL)); + VirtualizationType.PARAVIRTUAL, Hypervisor.XEN)); + Set result = parseImages("/describe_images_windows.xml"); @@ -81,7 +83,7 @@ public class DescribeImagesResponseHandlerTest { ImageState.AVAILABLE, ImageType.MACHINE, true, Sets. newHashSet(), null, "windows", null, RootDeviceType.EBS, "/dev/sda1", ImmutableMap. of("/dev/sda1", new EbsBlockDevice("snap-d01272b9", 30, true), "xvdf", new EbsBlockDevice("snap-d31272ba", 250, - false)), VirtualizationType.HVM)); + false)), VirtualizationType.HVM, Hypervisor.XEN)); Set result = parseImages("/describe_images_ebs.xml"); diff --git a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/compute/strategy/AWSEC2ImageParserTest.java b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/compute/strategy/AWSEC2ImageParserTest.java index b4879582ec..539ca04da4 100644 --- a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/compute/strategy/AWSEC2ImageParserTest.java +++ b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/compute/strategy/AWSEC2ImageParserTest.java @@ -125,11 +125,11 @@ public class AWSEC2ImageParserTest { assertEquals( new Gson().toJson(Iterables.get(result, 1)), - "{\"operatingSystem\":{\"family\":\"UBUNTU\",\"arch\":\"paravirtual\",\"version\":\"9.10\",\"description\":\"411009282317/RightImage_Ubuntu_9.10_x64_v4.5.3_EBS_Alpha\",\"is64Bit\":true},\"version\":\"4.5.3_EBS_Alpha\",\"description\":\"RightImage_Ubuntu_9.10_x64_v4.5.3_EBS_Alpha\",\"defaultCredentials\":{\"identity\":\"root\"},\"id\":\"us-east-1/ami-c19db6b5\",\"type\":\"IMAGE\",\"tags\":[],\"providerId\":\"ami-c19db6b5\",\"location\":{\"scope\":\"REGION\",\"id\":\"us-east-1\",\"description\":\"us-east-1\",\"iso3166Codes\":[],\"metadata\":{}},\"userMetadata\":{\"owner\":\"411009282317\",\"rootDeviceType\":\"ebs\"}}"); + "{\"operatingSystem\":{\"family\":\"UBUNTU\",\"arch\":\"paravirtual\",\"version\":\"9.10\",\"description\":\"411009282317/RightImage_Ubuntu_9.10_x64_v4.5.3_EBS_Alpha\",\"is64Bit\":true},\"version\":\"4.5.3_EBS_Alpha\",\"description\":\"RightImage_Ubuntu_9.10_x64_v4.5.3_EBS_Alpha\",\"defaultCredentials\":{\"identity\":\"root\"},\"id\":\"us-east-1/ami-c19db6b5\",\"type\":\"IMAGE\",\"tags\":[],\"providerId\":\"ami-c19db6b5\",\"location\":{\"scope\":\"REGION\",\"id\":\"us-east-1\",\"description\":\"us-east-1\",\"iso3166Codes\":[],\"metadata\":{}},\"userMetadata\":{\"owner\":\"411009282317\",\"rootDeviceType\":\"ebs\",\"virtualizationType\":\"paravirtual\",\"hypervisor\":\"xen\"}}"); assertEquals( new Gson().toJson(Iterables.get(result, 2)), - "{\"operatingSystem\":{\"family\":\"WINDOWS\",\"arch\":\"hvm\",\"version\":\"2003\",\"description\":\"411009282317/RightImage Windows_2003_i386_v5.4.3\",\"is64Bit\":false},\"version\":\"5.4.3\",\"description\":\"Built by RightScale\",\"defaultCredentials\":{\"identity\":\"root\"},\"id\":\"us-east-1/ami-710c2605\",\"type\":\"IMAGE\",\"tags\":[],\"providerId\":\"ami-710c2605\",\"location\":{\"scope\":\"REGION\",\"id\":\"us-east-1\",\"description\":\"us-east-1\",\"iso3166Codes\":[],\"metadata\":{}},\"userMetadata\":{\"owner\":\"411009282317\",\"rootDeviceType\":\"ebs\"}}"); + "{\"operatingSystem\":{\"family\":\"WINDOWS\",\"arch\":\"hvm\",\"version\":\"2003\",\"description\":\"411009282317/RightImage Windows_2003_i386_v5.4.3\",\"is64Bit\":false},\"version\":\"5.4.3\",\"description\":\"Built by RightScale\",\"defaultCredentials\":{\"identity\":\"root\"},\"id\":\"us-east-1/ami-710c2605\",\"type\":\"IMAGE\",\"tags\":[],\"providerId\":\"ami-710c2605\",\"location\":{\"scope\":\"REGION\",\"id\":\"us-east-1\",\"description\":\"us-east-1\",\"iso3166Codes\":[],\"metadata\":{}},\"userMetadata\":{\"owner\":\"411009282317\",\"rootDeviceType\":\"ebs\",\"virtualizationType\":\"hvm\",\"hypervisor\":\"xen\"}}"); } public void testParseAmznImage() { diff --git a/providers/eucalyptus-partnercloud-ec2/src/test/java/org/jclouds/epc/compute/strategy/EucalyptusPartnerCloudReviseParsedImageTest.java b/providers/eucalyptus-partnercloud-ec2/src/test/java/org/jclouds/epc/compute/strategy/EucalyptusPartnerCloudReviseParsedImageTest.java index db061a6a74..aff487a339 100644 --- a/providers/eucalyptus-partnercloud-ec2/src/test/java/org/jclouds/epc/compute/strategy/EucalyptusPartnerCloudReviseParsedImageTest.java +++ b/providers/eucalyptus-partnercloud-ec2/src/test/java/org/jclouds/epc/compute/strategy/EucalyptusPartnerCloudReviseParsedImageTest.java @@ -66,7 +66,8 @@ public class EucalyptusPartnerCloudReviseParsedImageTest { "debian-6.0-x86_64/debian.6-0.x86-64.img.manifest.xml") .defaultCredentials(new Credentials("root", null)).id("us-east-1/emi-892C130F").providerId( "emi-892C130F").location(defaultLocation).userMetadata( - ImmutableMap.of("owner", "admin", "rootDeviceType", "instance-store")).build().toString()); + ImmutableMap.of("owner", "admin", "rootDeviceType", "instance-store", "virtualizationType", + "paravirtual", "hypervisor", "xen")).build().toString()); assertEquals(Iterables.get(result, 1).toString(), new ImageBuilder().operatingSystem( OperatingSystem.builder().family(OsFamily.CENTOS).arch("paravirtual").version("5.5").description( @@ -74,15 +75,17 @@ public class EucalyptusPartnerCloudReviseParsedImageTest { "centos-5.5-x86_64/centos.5-5.x86-64.img.manifest.xml") .defaultCredentials(new Credentials("root", null)).id("us-east-1/emi-9B751369").providerId( "emi-9B751369").location(defaultLocation).userMetadata( - ImmutableMap.of("owner", "admin", "rootDeviceType", "instance-store")).build().toString()); + ImmutableMap.of("owner", "admin", "rootDeviceType", "instance-store", "virtualizationType", + "paravirtual", "hypervisor", "xen")).build().toString()); assertEquals(Iterables.get(result, 2).toString(), new ImageBuilder().operatingSystem( OperatingSystem.builder().family(OsFamily.UBUNTU).arch("paravirtual").version("10.04").description( "ubuntu-10.04-x86_64/ubuntu.10-04.x86-64.img.manifest.xml").is64Bit(true).build()).description( "ubuntu-10.04-x86_64/ubuntu.10-04.x86-64.img.manifest.xml").defaultCredentials( new Credentials("root", null)).id("us-east-1/emi-E0641459").providerId("emi-E0641459").location( - defaultLocation).userMetadata(ImmutableMap.of("owner", "admin", "rootDeviceType", "instance-store")) - .build().toString()); + defaultLocation).userMetadata( + ImmutableMap.of("owner", "admin", "rootDeviceType", "instance-store", "virtualizationType", + "paravirtual", "hypervisor", "xen")).build().toString()); } From 3c200645bca69678adb0c55998f9cac76825dca5 Mon Sep 17 00:00:00 2001 From: Adrian Cole Date: Fri, 8 Jul 2011 02:10:35 -0700 Subject: [PATCH 122/264] added ec2 support for image filters --- .../ec2/options/DescribeImagesOptions.java | 5 + .../ec2/options/AWSDescribeImagesOptions.java | 154 +++++++++++++++ .../options/AWSDescribeImagesOptionsTest.java | 180 ++++++++++++++++++ 3 files changed, 339 insertions(+) create mode 100644 providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/options/AWSDescribeImagesOptions.java create mode 100644 providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/options/AWSDescribeImagesOptionsTest.java diff --git a/apis/ec2/src/main/java/org/jclouds/ec2/options/DescribeImagesOptions.java b/apis/ec2/src/main/java/org/jclouds/ec2/options/DescribeImagesOptions.java index b84b5c836f..5e5f1d6182 100644 --- a/apis/ec2/src/main/java/org/jclouds/ec2/options/DescribeImagesOptions.java +++ b/apis/ec2/src/main/java/org/jclouds/ec2/options/DescribeImagesOptions.java @@ -66,6 +66,11 @@ public class DescribeImagesOptions extends BaseEC2RequestOptions { return this; } + public DescribeImagesOptions imageIds(Iterable imageIds) { + indexFormValuesWithPrefix("ImageId", imageIds); + return this; + } + public Set getImageIds() { return getFormValuesWithKeysPrefixedBy("ImageId."); } diff --git a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/options/AWSDescribeImagesOptions.java b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/options/AWSDescribeImagesOptions.java new file mode 100644 index 0000000000..9b8f6cffab --- /dev/null +++ b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/options/AWSDescribeImagesOptions.java @@ -0,0 +1,154 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.jclouds.aws.ec2.options; + +import static com.google.common.base.Preconditions.checkNotNull; + +import java.util.Collection; +import java.util.Map; +import java.util.Map.Entry; + +import org.jclouds.ec2.options.DescribeImagesOptions; + +import com.google.common.collect.Multimap; +import com.google.common.collect.Multimaps; + +/** + * Extra options only available in Amazon's implementation + * + * @see DescribeImagesOptions + * @author Adrian Cole + */ +public class AWSDescribeImagesOptions extends DescribeImagesOptions { + public static final AWSDescribeImagesOptions NONE = new AWSDescribeImagesOptions(); + + /** + * {@inheritDoc} + */ + @Override + public AWSDescribeImagesOptions executableBy(String identityId) { + super.executableBy(identityId); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public AWSDescribeImagesOptions imageIds(String... imageIds) { + super.imageIds(imageIds); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public AWSDescribeImagesOptions imageIds(Iterable imageIds) { + super.imageIds(imageIds); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public AWSDescribeImagesOptions ownedBy(String... owners) { + super.ownedBy(owners); + return this; + } + + /** + * You can filter the results to return information only about images that match criteria you + * specify. For example, you could get information only about images that use a certain kernel. + * You can specify multiple values for a filter (e.g., the image uses either kernel aki-1a2b3c4d + * or kernel aki-9b8c7d6f). An image must match at least one of the specified values for it to be + * included in the results. + *

    + * You can specify multiple filters (e.g., the image uses a certain kernel, and uses an Amazon + * EBS volume as the root device). The result includes information for a particular image only if + * it matches all your filters. If there's no match, no special message is returned; the response + * is simply empty. + *

    + * You can use wildcards with the filter values: * matches zero or more characters, and ? matches + * exactly one character. You can escape special characters using a backslash before the + * character. For example, a value of \*amazon\?\\ searches for the literal string *amazon?\. + * + */ + public AWSDescribeImagesOptions filters(Multimap filters) { + int i = 0; + for (Entry> filter : checkNotNull(filters, "filters").asMap().entrySet()) { + String filterPrefix = String.format("Filter.%s.", ++i); + formParameters.put(filterPrefix + "Name", filter.getKey()); + indexFormValuesWithPrefix(filterPrefix + "Value", filter.getValue()); + } + return this; + } + + /** + * @see #filters(Multimap) + */ + public AWSDescribeImagesOptions filters(Map filters) { + return filters(Multimaps.forMap(checkNotNull(filters, "filters"))); + } + + public static class Builder extends DescribeImagesOptions.Builder { + + /** + * @see AWSDescribeImagesOptions#executableBy + */ + public static AWSDescribeImagesOptions executableBy(String identityId) { + AWSDescribeImagesOptions options = new AWSDescribeImagesOptions(); + return options.executableBy(identityId); + } + + /** + * @see AWSDescribeImagesOptions#imageIds + */ + public static AWSDescribeImagesOptions imageIds(String... imageIds) { + AWSDescribeImagesOptions options = new AWSDescribeImagesOptions(); + return options.imageIds(imageIds); + } + + /** + * @see AWSDescribeImagesOptions#filters(Multimap) + */ + public static AWSDescribeImagesOptions filters(Multimap filters) { + AWSDescribeImagesOptions options = new AWSDescribeImagesOptions(); + return options.filters(filters); + } + + /** + * @see AWSDescribeImagesOptions#filters(Map) + */ + public static AWSDescribeImagesOptions filters(Map filters) { + AWSDescribeImagesOptions options = new AWSDescribeImagesOptions(); + return options.filters(filters); + } + + /** + * @see AWSDescribeImagesOptions#ownedBy + */ + public static AWSDescribeImagesOptions ownedBy(String... owners) { + AWSDescribeImagesOptions options = new AWSDescribeImagesOptions(); + return options.ownedBy(owners); + } + + } +} diff --git a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/options/AWSDescribeImagesOptionsTest.java b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/options/AWSDescribeImagesOptionsTest.java new file mode 100644 index 0000000000..505349bef0 --- /dev/null +++ b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/options/AWSDescribeImagesOptionsTest.java @@ -0,0 +1,180 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.jclouds.aws.ec2.options; + +import static org.jclouds.aws.ec2.options.AWSDescribeImagesOptions.Builder.executableBy; +import static org.jclouds.aws.ec2.options.AWSDescribeImagesOptions.Builder.filters; +import static org.jclouds.aws.ec2.options.AWSDescribeImagesOptions.Builder.imageIds; +import static org.jclouds.aws.ec2.options.AWSDescribeImagesOptions.Builder.ownedBy; +import static org.testng.Assert.assertEquals; + +import java.util.Collections; + +import org.jclouds.http.options.HttpRequestOptions; +import org.testng.annotations.Test; + +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableMultimap; + +/** + * Tests possible uses of AWSDescribeImagesOptions and AWSDescribeImagesOptions.Builder.* + * + * @author Adrian Cole + */ +public class AWSDescribeImagesOptionsTest { + + @Test + public void testAssignability() { + assert HttpRequestOptions.class.isAssignableFrom(AWSDescribeImagesOptions.class); + assert !String.class.isAssignableFrom(AWSDescribeImagesOptions.class); + } + + @Test + public void testExecutableBy() { + AWSDescribeImagesOptions options = new AWSDescribeImagesOptions(); + options.executableBy("test"); + assertEquals(options.buildFormParameters().get("ExecutableBy"), Collections.singletonList("test")); + } + + @Test + public void testNullExecutableBy() { + AWSDescribeImagesOptions options = new AWSDescribeImagesOptions(); + assertEquals(options.buildFormParameters().get("ExecutableBy"), Collections.EMPTY_LIST); + } + + @Test + public void testExecutableByStatic() { + AWSDescribeImagesOptions options = executableBy("test"); + assertEquals(options.buildFormParameters().get("ExecutableBy"), Collections.singletonList("test")); + } + + @Test(expectedExceptions = NullPointerException.class) + public void testExecutableByNPE() { + executableBy(null); + } + + @Test + public void testOwners() { + AWSDescribeImagesOptions options = new AWSDescribeImagesOptions(); + options.ownedBy("test"); + assertEquals(options.buildFormParameters().get("Owner.1"), Collections.singletonList("test")); + } + + @Test + public void testMultipleOwners() { + AWSDescribeImagesOptions options = new AWSDescribeImagesOptions(); + options.ownedBy("test", "trouble"); + assertEquals(options.buildFormParameters().get("Owner.1"), Collections.singletonList("test")); + assertEquals(options.buildFormParameters().get("Owner.2"), Collections.singletonList("trouble")); + } + + @Test + public void testNullOwners() { + AWSDescribeImagesOptions options = new AWSDescribeImagesOptions(); + assertEquals(options.buildFormParameters().get("Owner.1"), Collections.EMPTY_LIST); + } + + @Test + public void testOwnersStatic() { + AWSDescribeImagesOptions options = ownedBy("test"); + assertEquals(options.buildFormParameters().get("Owner.1"), Collections.singletonList("test")); + } + + public void testNoOwners() { + ownedBy(); + } + + @Test + public void testImageIds() { + AWSDescribeImagesOptions options = new AWSDescribeImagesOptions(); + options.imageIds("test"); + assertEquals(options.buildFormParameters().get("ImageId.1"), Collections.singletonList("test")); + } + + @Test + public void testMultipleImageIds() { + AWSDescribeImagesOptions options = new AWSDescribeImagesOptions(); + options.imageIds("test", "trouble"); + assertEquals(options.buildFormParameters().get("ImageId.1"), Collections.singletonList("test")); + assertEquals(options.buildFormParameters().get("ImageId.2"), Collections.singletonList("trouble")); + } + + @Test + public void testNullImageIds() { + AWSDescribeImagesOptions options = new AWSDescribeImagesOptions(); + assertEquals(options.buildFormParameters().get("ImageId.1"), Collections.EMPTY_LIST); + } + + @Test + public void testImageIdsStatic() { + AWSDescribeImagesOptions options = imageIds("test"); + assertEquals(options.buildFormParameters().get("ImageId.1"), Collections.singletonList("test")); + } + + public void testNoImageIds() { + imageIds(); + } + + @Test + public void testMapFilters() { + AWSDescribeImagesOptions options = new AWSDescribeImagesOptions(); + options.filters(ImmutableMap.of("is-public", "true", "architecture", "x86_64", "platform", "windows")); + testMapFilters(options); + } + + private void testMapFilters(AWSDescribeImagesOptions options) { + assertEquals(options.buildFormParameters().get("Filter.1.Name"), Collections.singletonList("is-public")); + assertEquals(options.buildFormParameters().get("Filter.1.Value.1"), Collections.singletonList("true")); + assertEquals(options.buildFormParameters().get("Filter.2.Name"), Collections.singletonList("architecture")); + assertEquals(options.buildFormParameters().get("Filter.2.Value.1"), Collections.singletonList("x86_64")); + assertEquals(options.buildFormParameters().get("Filter.3.Name"), Collections.singletonList("platform")); + assertEquals(options.buildFormParameters().get("Filter.3.Value.1"), Collections.singletonList("windows")); + } + + @Test + public void testMapFiltersStatic() { + AWSDescribeImagesOptions options = filters(ImmutableMap.of("is-public", "true", "architecture", "x86_64", + "platform", "windows")); + testMapFilters(options); + } + + + @Test + public void testMultimapFilters() { + AWSDescribeImagesOptions options = new AWSDescribeImagesOptions(); + options.filters(ImmutableMultimap.of("is-public", "true", "architecture", "x86_64", "platform", "windows")); + testMultimapFilters(options); + } + + private void testMultimapFilters(AWSDescribeImagesOptions options) { + assertEquals(options.buildFormParameters().get("Filter.1.Name"), Collections.singletonList("is-public")); + assertEquals(options.buildFormParameters().get("Filter.1.Value.1"), Collections.singletonList("true")); + assertEquals(options.buildFormParameters().get("Filter.2.Name"), Collections.singletonList("architecture")); + assertEquals(options.buildFormParameters().get("Filter.2.Value.1"), Collections.singletonList("x86_64")); + assertEquals(options.buildFormParameters().get("Filter.3.Name"), Collections.singletonList("platform")); + assertEquals(options.buildFormParameters().get("Filter.3.Value.1"), Collections.singletonList("windows")); + } + + @Test + public void testMultimapFiltersStatic() { + AWSDescribeImagesOptions options = filters(ImmutableMultimap.of("is-public", "true", "architecture", "x86_64", + "platform", "windows")); + testMultimapFilters(options); + } +} From 6e2cf793b2ee1296c32a8b16c8171b9e26ad26a2 Mon Sep 17 00:00:00 2001 From: Adrian Cole Date: Fri, 8 Jul 2011 02:12:39 -0700 Subject: [PATCH 123/264] Issue 613:Automatically parse cluster ami list --- .../EC2ComputeServiceContextModule.java | 13 ++ .../EC2ComputeServiceDependenciesModule.java | 14 +- .../compute/domain/EC2HardwareBuilder.java | 7 +- .../RegionAndNameToImageSupplier.java | 9 +- .../ec2/compute/EC2TemplateBuilderTest.java | 2 +- .../RunningInstanceToNodeMetadataTest.java | 3 +- .../aws/ec2/AWSEC2PropertiesBuilder.java | 54 ++++++- .../AWSEC2ComputeServiceContextModule.java | 46 ++++-- ...WSEC2ComputeServiceDependenciesModule.java | 17 +- .../ec2/compute/config/ClusterCompute.java | 21 +++ .../suppliers/AWSEC2HardwareSupplier.java | 30 +--- .../AWSRegionAndNameToImageSupplier.java | 153 ++++++++++++------ .../ec2/compute/suppliers/CallForImages.java | 96 +++++++++++ .../aws/ec2/reference/AWSEC2Constants.java | 12 ++ .../aws/ec2/AWSEC2PropertiesBuilderTest.java | 68 ++++++++ .../AWSEC2TemplateBuilderLiveTest.java | 24 ++- .../aws/ec2/services/AMIClientLiveTest.java | 51 ++++-- .../ec2/services/AWSAMIAsyncClientTest.java | 17 +- .../ec2/services/AWSAMIClientLiveTest.java | 4 +- .../PlacementGroupClientLiveTest.java | 29 +--- 20 files changed, 495 insertions(+), 175 deletions(-) create mode 100644 providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/config/ClusterCompute.java create mode 100644 providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/suppliers/CallForImages.java create mode 100644 providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/AWSEC2PropertiesBuilderTest.java diff --git a/apis/ec2/src/main/java/org/jclouds/ec2/compute/config/EC2ComputeServiceContextModule.java b/apis/ec2/src/main/java/org/jclouds/ec2/compute/config/EC2ComputeServiceContextModule.java index 8ab5bb24fe..6d71131b65 100644 --- a/apis/ec2/src/main/java/org/jclouds/ec2/compute/config/EC2ComputeServiceContextModule.java +++ b/apis/ec2/src/main/java/org/jclouds/ec2/compute/config/EC2ComputeServiceContextModule.java @@ -18,7 +18,9 @@ */ package org.jclouds.ec2.compute.config; +import static com.google.common.collect.Iterables.toArray; import static org.jclouds.Constants.PROPERTY_SESSION_INTERVAL; +import static org.jclouds.ec2.reference.EC2Constants.PROPERTY_EC2_AMI_OWNERS; import java.util.Map; @@ -33,6 +35,7 @@ import org.jclouds.ec2.compute.domain.RegionAndName; import org.jclouds.ec2.compute.suppliers.RegionAndNameToImageSupplier; import org.jclouds.rest.suppliers.MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier; +import com.google.common.base.Splitter; import com.google.common.base.Supplier; import com.google.inject.Provides; @@ -67,4 +70,14 @@ public class EC2ComputeServiceContextModule extends BaseComputeServiceContextMod }); } + @Provides + @Singleton + @Named(PROPERTY_EC2_AMI_OWNERS) + String[] amiOwners(@Named(PROPERTY_EC2_AMI_OWNERS) String amiOwners) { + if (amiOwners.trim().equals("")) + return new String[] {}; + return toArray(Splitter.on(',').split(amiOwners), String.class); + } + } + diff --git a/apis/ec2/src/main/java/org/jclouds/ec2/compute/config/EC2ComputeServiceDependenciesModule.java b/apis/ec2/src/main/java/org/jclouds/ec2/compute/config/EC2ComputeServiceDependenciesModule.java index 8c2dfffe3b..d123b71846 100644 --- a/apis/ec2/src/main/java/org/jclouds/ec2/compute/config/EC2ComputeServiceDependenciesModule.java +++ b/apis/ec2/src/main/java/org/jclouds/ec2/compute/config/EC2ComputeServiceDependenciesModule.java @@ -18,9 +18,7 @@ */ package org.jclouds.ec2.compute.config; -import static com.google.common.collect.Iterables.toArray; import static com.google.common.collect.Maps.newLinkedHashMap; -import static org.jclouds.ec2.reference.EC2Constants.PROPERTY_EC2_AMI_OWNERS; import java.security.SecureRandom; import java.util.Map; @@ -56,7 +54,6 @@ import org.jclouds.rest.RestContext; import org.jclouds.rest.internal.RestContextImpl; import com.google.common.base.Function; -import com.google.common.base.Splitter; import com.google.common.base.Supplier; import com.google.common.collect.ImmutableMap; import com.google.common.collect.MapMaker; @@ -137,16 +134,7 @@ public class EC2ComputeServiceDependenciesModule extends AbstractModule { // return new MapMaker().makeComputingMap(in); return newLinkedHashMap(); } - - @Provides - @Singleton - @Named(PROPERTY_EC2_AMI_OWNERS) - String[] amiOwners(@Named(PROPERTY_EC2_AMI_OWNERS) String amiOwners) { - if (amiOwners.trim().equals("")) - return new String[] {}; - return toArray(Splitter.on(',').split(amiOwners), String.class); - } - + @Provides @Singleton protected Map provideImageMap(Function regionAndIdToImage) { diff --git a/apis/ec2/src/main/java/org/jclouds/ec2/compute/domain/EC2HardwareBuilder.java b/apis/ec2/src/main/java/org/jclouds/ec2/compute/domain/EC2HardwareBuilder.java index 2e10e9f7cc..6e0d7b6b26 100644 --- a/apis/ec2/src/main/java/org/jclouds/ec2/compute/domain/EC2HardwareBuilder.java +++ b/apis/ec2/src/main/java/org/jclouds/ec2/compute/domain/EC2HardwareBuilder.java @@ -18,14 +18,12 @@ */ package org.jclouds.ec2.compute.domain; -import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Predicates.not; import static org.jclouds.compute.predicates.ImagePredicates.any; import static org.jclouds.compute.predicates.ImagePredicates.idIn; import java.net.URI; -import java.util.Arrays; import java.util.List; import java.util.Map; @@ -146,9 +144,8 @@ public class EC2HardwareBuilder extends HardwareBuilder { return this; } - public EC2HardwareBuilder supportsImageIds(String... ids) { - checkArgument(ids != null && ids.length > 0, "ids must be specified"); - this.imageIds = idIn(Arrays.asList(ids)); + public EC2HardwareBuilder supportsImageIds(Iterable ids) { + this.imageIds = idIn(ids); return this; } diff --git a/apis/ec2/src/main/java/org/jclouds/ec2/compute/suppliers/RegionAndNameToImageSupplier.java b/apis/ec2/src/main/java/org/jclouds/ec2/compute/suppliers/RegionAndNameToImageSupplier.java index cc2340a06f..00a80f512e 100644 --- a/apis/ec2/src/main/java/org/jclouds/ec2/compute/suppliers/RegionAndNameToImageSupplier.java +++ b/apis/ec2/src/main/java/org/jclouds/ec2/compute/suppliers/RegionAndNameToImageSupplier.java @@ -65,6 +65,7 @@ import com.google.common.base.Function; import com.google.common.base.Predicates; import com.google.common.base.Supplier; import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableMap.Builder; /** @@ -103,8 +104,8 @@ public class RegionAndNameToImageSupplier implements Supplier> queries = getDescribeQueriesForOwnersInRegions(regions, amiOwners); - Iterable parsedImages = filter(transform(describer.apply(queries), parser), Predicates - .notNull()); + Iterable parsedImages = ImmutableSet.copyOf(filter(transform(describer.apply(queries), parser), Predicates + .notNull())); images.putAll(uniqueIndex(parsedImages, new Function() { @@ -129,8 +130,8 @@ public class RegionAndNameToImageSupplier implements Supplier> provideRegionAndNameToImageSupplierCache( + @Named(PROPERTY_SESSION_INTERVAL) long seconds, final AWSRegionAndNameToImageSupplier supplier) { + return new MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier>( + authException, seconds, new Supplier>() { + @Override + public Map get() { + return supplier.get(); + } + }); + } + + @Override + protected TemplateBuilder provideTemplate(Injector injector, TemplateBuilder template) { + return template.osFamily(AMZN_LINUX).os64Bit(true); + } } diff --git a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/config/AWSEC2ComputeServiceDependenciesModule.java b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/config/AWSEC2ComputeServiceDependenciesModule.java index 2158c57f79..4815dab75e 100644 --- a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/config/AWSEC2ComputeServiceDependenciesModule.java +++ b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/config/AWSEC2ComputeServiceDependenciesModule.java @@ -18,11 +18,10 @@ */ package org.jclouds.aws.ec2.compute.config; -import static com.google.common.collect.Iterables.toArray; import static com.google.common.collect.Maps.newLinkedHashMap; -import static org.jclouds.aws.ec2.reference.AWSEC2Constants.PROPERTY_EC2_CC_AMIs; import java.util.Map; +import java.util.Set; import java.util.concurrent.TimeUnit; import javax.inject.Named; @@ -32,6 +31,7 @@ import org.jclouds.aws.ec2.AWSEC2AsyncClient; import org.jclouds.aws.ec2.AWSEC2Client; import org.jclouds.aws.ec2.compute.AWSEC2ComputeService; import org.jclouds.aws.ec2.compute.AWSEC2TemplateOptions; +import org.jclouds.aws.ec2.compute.suppliers.CallForImages; import org.jclouds.aws.ec2.domain.PlacementGroup; import org.jclouds.aws.ec2.domain.RegionNameAndPublicKeyMaterial; import org.jclouds.aws.ec2.functions.ImportOrReturnExistingKeypair; @@ -62,10 +62,11 @@ import org.jclouds.rest.internal.RestContextImpl; import com.google.common.base.Function; import com.google.common.base.Predicate; -import com.google.common.base.Splitter; +import com.google.common.collect.Sets; import com.google.inject.Provides; import com.google.inject.Scopes; import com.google.inject.TypeLiteral; +import com.google.inject.assistedinject.FactoryModuleBuilder; /** * @@ -95,6 +96,7 @@ public class AWSEC2ComputeServiceDependenciesModule extends EC2ComputeServiceDep bind(new TypeLiteral>() { }).to(new TypeLiteral>() { }).in(Scopes.SINGLETON); + install(new FactoryModuleBuilder().build(CallForImages.Factory.class)); } @Provides @@ -121,11 +123,10 @@ public class AWSEC2ComputeServiceDependenciesModule extends EC2ComputeServiceDep } @Provides + @ClusterCompute @Singleton - @Named(PROPERTY_EC2_CC_AMIs) - protected String[] ccAmis(@Named(PROPERTY_EC2_CC_AMIs) String ccAmis) { - if (ccAmis.trim().equals("")) - return new String[] {}; - return toArray(Splitter.on(',').split(ccAmis), String.class); + protected Set provideClusterComputeIds() { + return Sets.newLinkedHashSet(); } + } diff --git a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/config/ClusterCompute.java b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/config/ClusterCompute.java new file mode 100644 index 0000000000..71b1d93ab7 --- /dev/null +++ b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/config/ClusterCompute.java @@ -0,0 +1,21 @@ +package org.jclouds.aws.ec2.compute.config; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +import javax.inject.Qualifier; + +/** + * Related to a ClusterCompute resource. + * + * @author Adrian Cole + * + */ +@Retention(value = RetentionPolicy.RUNTIME) +@Target(value = { ElementType.FIELD, ElementType.PARAMETER, ElementType.METHOD }) +@Qualifier +public @interface ClusterCompute { + +} \ No newline at end of file diff --git a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/suppliers/AWSEC2HardwareSupplier.java b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/suppliers/AWSEC2HardwareSupplier.java index e16ff71084..951567f963 100644 --- a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/suppliers/AWSEC2HardwareSupplier.java +++ b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/suppliers/AWSEC2HardwareSupplier.java @@ -18,8 +18,6 @@ */ package org.jclouds.aws.ec2.compute.suppliers; -import static com.google.common.collect.Iterables.find; -import static org.jclouds.aws.ec2.reference.AWSEC2Constants.PROPERTY_EC2_CC_AMIs; import static org.jclouds.ec2.compute.domain.EC2HardwareBuilder.c1_medium; import static org.jclouds.ec2.compute.domain.EC2HardwareBuilder.c1_xlarge; import static org.jclouds.ec2.compute.domain.EC2HardwareBuilder.cc1_4xlarge; @@ -34,18 +32,12 @@ import static org.jclouds.ec2.compute.domain.EC2HardwareBuilder.t1_micro; import java.util.Set; import javax.inject.Inject; -import javax.inject.Named; import javax.inject.Singleton; -import org.jclouds.collect.Memoized; +import org.jclouds.aws.ec2.compute.config.ClusterCompute; import org.jclouds.compute.domain.Hardware; -import org.jclouds.domain.Location; -import org.jclouds.domain.LocationScope; import org.jclouds.ec2.compute.suppliers.EC2HardwareSupplier; -import org.jclouds.location.Provider; -import com.google.common.base.Predicate; -import com.google.common.base.Supplier; import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet.Builder; @@ -56,31 +48,17 @@ import com.google.common.collect.ImmutableSet.Builder; @Singleton public class AWSEC2HardwareSupplier extends EC2HardwareSupplier { - private final Supplier> locations; - private final String[] ccAmis; + private final Set ccAmis; @Inject - public AWSEC2HardwareSupplier(@Memoized Supplier> locations, @Provider String providerName, - @Named(PROPERTY_EC2_CC_AMIs) String[] ccAmis) { - this.locations = locations; + public AWSEC2HardwareSupplier(@ClusterCompute Set ccAmis) { this.ccAmis = ccAmis; } @Override public Set get() { Builder sizes = ImmutableSet.builder(); - for (String ccAmi : ccAmis) { - final String region = ccAmi.split("/")[0]; - Location location = find(locations.get(), new Predicate() { - - @Override - public boolean apply(Location input) { - return input.getScope() == LocationScope.REGION && input.getId().equals(region); - } - - }); - sizes.add(cc1_4xlarge().location(location).supportsImageIds(ccAmi).build()); - } + sizes.add(cc1_4xlarge().supportsImageIds(ccAmis).build()); sizes.addAll(ImmutableSet. of(t1_micro().build(), c1_medium().build(), c1_xlarge().build(), m1_large() .build(), m1_small32().build(), m1_xlarge().build(), m2_xlarge().build(), m2_2xlarge().build(), m2_4xlarge().build())); diff --git a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/suppliers/AWSRegionAndNameToImageSupplier.java b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/suppliers/AWSRegionAndNameToImageSupplier.java index 0dd11a709f..dd4345521a 100644 --- a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/suppliers/AWSRegionAndNameToImageSupplier.java +++ b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/suppliers/AWSRegionAndNameToImageSupplier.java @@ -18,75 +18,138 @@ */ package org.jclouds.aws.ec2.compute.suppliers; -/** - * - * - * ==================================================================== - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ==================================================================== - */ - import static com.google.common.collect.Iterables.concat; -import static com.google.common.collect.Maps.newLinkedHashMap; -import static org.jclouds.aws.ec2.reference.AWSEC2Constants.PROPERTY_EC2_CC_AMIs; -import static org.jclouds.ec2.options.DescribeImagesOptions.Builder.imageIds; -import static org.jclouds.ec2.reference.EC2Constants.PROPERTY_EC2_AMI_OWNERS; +import static com.google.common.collect.Iterables.transform; +import static com.google.common.collect.Maps.uniqueIndex; +import static org.jclouds.aws.ec2.reference.AWSEC2Constants.PROPERTY_EC2_AMI_QUERY; +import static org.jclouds.aws.ec2.reference.AWSEC2Constants.PROPERTY_EC2_CC_AMI_QUERY; +import static org.jclouds.aws.ec2.reference.AWSEC2Constants.PROPERTY_EC2_CC_REGIONS; import java.util.Map; import java.util.Set; -import java.util.Map.Entry; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Future; +import javax.annotation.Resource; import javax.inject.Inject; import javax.inject.Named; import javax.inject.Singleton; +import org.jclouds.Constants; +import org.jclouds.aws.ec2.compute.config.ClusterCompute; import org.jclouds.compute.domain.Image; +import org.jclouds.compute.reference.ComputeServiceConstants; import org.jclouds.ec2.compute.domain.RegionAndName; -import org.jclouds.ec2.compute.functions.EC2ImageParser; -import org.jclouds.ec2.compute.strategy.DescribeImagesParallel; -import org.jclouds.ec2.compute.suppliers.RegionAndNameToImageSupplier; -import org.jclouds.ec2.options.DescribeImagesOptions; import org.jclouds.location.Region; +import org.jclouds.logging.Logger; + +import com.google.common.base.Function; +import com.google.common.base.Splitter; +import com.google.common.base.Supplier; +import com.google.common.base.Throwables; +import com.google.common.collect.ImmutableMultimap; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Iterables; +import com.google.common.collect.Multimap; +import com.google.common.util.concurrent.Futures; /** * * @author Adrian Cole */ @Singleton -public class AWSRegionAndNameToImageSupplier extends RegionAndNameToImageSupplier { +public class AWSRegionAndNameToImageSupplier implements Supplier> { + @Resource + @Named(ComputeServiceConstants.COMPUTE_LOGGER) + protected Logger logger = Logger.NULL; - private final String[] ccAmis; + private final Map images; + private final Set clusterComputeIds; + private final CallForImages.Factory factory; + private final ExecutorService executor; + + private final Iterable regions; + private final String amiQuery; + private final Iterable clusterRegions; + private final String ccAmiQuery; @Inject - AWSRegionAndNameToImageSupplier(@Region Set regions, DescribeImagesParallel describer, - @Named(PROPERTY_EC2_CC_AMIs) String[] ccAmis, @Named(PROPERTY_EC2_AMI_OWNERS) String[] amiOwners, - EC2ImageParser parser, Map images) { - super(regions, describer, amiOwners, parser, images); - this.ccAmis = ccAmis; + protected AWSRegionAndNameToImageSupplier(@Region Set regions, + @Named(PROPERTY_EC2_AMI_QUERY) String amiQuery, @Named(PROPERTY_EC2_CC_REGIONS) String clusterRegions, + @Named(PROPERTY_EC2_CC_AMI_QUERY) String ccAmiQuery, Map images, + CallForImages.Factory factory, @ClusterCompute Set clusterComputeIds, + @Named(Constants.PROPERTY_USER_THREADS) ExecutorService executor) { + this.factory = factory; + this.regions = regions; + this.amiQuery = amiQuery; + this.clusterRegions = Splitter.on(',').split(clusterRegions); + this.ccAmiQuery = ccAmiQuery; + this.images = images; + this.clusterComputeIds = clusterComputeIds; + this.executor = executor; } - public Iterable> getDescribeQueriesForOwnersInRegions(Set regions, - String[] amiOwners) { - return concat(super.getDescribeQueriesForOwnersInRegions(regions, amiOwners), ccAmisToDescribeQueries(ccAmis) - .entrySet()); - } - - static Map ccAmisToDescribeQueries(String[] ccAmis) { - Map queries = newLinkedHashMap(); - for (String from : ccAmis) { - queries.put(from.split("/")[0], imageIds(from.split("/")[1])); + @Override + public Map get() { + Future> normalImages = images(regions, amiQuery, PROPERTY_EC2_AMI_QUERY); + ImmutableSet clusterImages; + try { + clusterImages = ImmutableSet.copyOf(images(clusterRegions, ccAmiQuery, PROPERTY_EC2_CC_AMI_QUERY).get()); + } catch (Exception e) { + logger.warn(e, "Error parsing images in query %s", ccAmiQuery); + Throwables.propagate(e); + return null; } - return queries; + Iterables.addAll(clusterComputeIds, transform(clusterImages, new Function() { + + @Override + public String apply(Image arg0) { + return arg0.getId(); + } + })); + Iterable parsedImages; + try { + parsedImages = ImmutableSet.copyOf(concat(clusterImages, normalImages.get())); + } catch (Exception e) { + logger.warn(e, "Error parsing images in query %s", amiQuery); + Throwables.propagate(e); + return null; + } + + images.putAll(uniqueIndex(parsedImages, new Function() { + + @Override + public RegionAndName apply(Image from) { + return new RegionAndName(from.getLocation().getId(), from.getProviderId()); + } + + })); + return images; } + private Future> images(Iterable regions, String query, String tag) { + if (query.equals("")) { + logger.debug(">> no %s specified, skipping image parsing", tag); + return Futures.> immediateFuture(ImmutableSet. of()); + } else { + return executor.submit(factory.parseImagesFromRegionsUsingFilter(regions, QueryStringToMultimap.INSTANCE + .apply(query))); + } + } + + public static enum QueryStringToMultimap implements Function> { + INSTANCE; + @Override + public Multimap apply(String arg0) { + ImmutableMultimap.Builder builder = ImmutableMultimap. builder(); + for (String pair : Splitter.on(';').split(arg0)) { + String[] keyValue = pair.split("="); + if (keyValue.length == 1) + builder.putAll(keyValue[0], ImmutableSet. of()); + else + builder.putAll(keyValue[0], Splitter.on(',').split(keyValue[1])); + } + return builder.build(); + } + } } diff --git a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/suppliers/CallForImages.java b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/suppliers/CallForImages.java new file mode 100644 index 0000000000..e95c7cf376 --- /dev/null +++ b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/suppliers/CallForImages.java @@ -0,0 +1,96 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.jclouds.aws.ec2.compute.suppliers; + +import static com.google.common.collect.Iterables.filter; +import static com.google.common.collect.Iterables.transform; +import static org.jclouds.aws.ec2.options.AWSDescribeImagesOptions.Builder.filters; + +import java.util.Map.Entry; +import java.util.concurrent.Callable; + +import javax.annotation.Resource; +import javax.inject.Inject; +import javax.inject.Named; +import javax.inject.Singleton; + +import org.jclouds.compute.domain.Image; +import org.jclouds.compute.reference.ComputeServiceConstants; +import org.jclouds.ec2.compute.functions.EC2ImageParser; +import org.jclouds.ec2.compute.strategy.DescribeImagesParallel; +import org.jclouds.ec2.options.DescribeImagesOptions; +import org.jclouds.logging.Logger; + +import com.google.common.base.Predicates; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.Iterables; +import com.google.common.collect.Multimap; +import com.google.common.collect.ImmutableMap.Builder; +import com.google.inject.assistedinject.Assisted; + +/** + * + * @author Adrian Cole + */ +@Singleton +public class CallForImages implements Callable> { + public interface Factory { + CallForImages parseImagesFromRegionsUsingFilter(Iterable regions, Multimap filter); + } + + @Resource + @Named(ComputeServiceConstants.COMPUTE_LOGGER) + protected Logger logger = Logger.NULL; + + private final Iterable regions; + private final DescribeImagesParallel describer; + private final EC2ImageParser parser; + private final Multimap filter; + + @Inject + protected CallForImages(DescribeImagesParallel describer, EC2ImageParser parser, @Assisted Iterable regions, + @Assisted Multimap filter) { + this.regions = regions; + this.describer = describer; + this.filter = filter; + this.parser = parser; + } + + public Iterable call() { + + logger.debug(">> providing images"); + + Builder builder = ImmutableMap. builder(); + for (String region : regions) + builder.put(region, filters(filter)); + + Iterable> queries = builder.build().entrySet(); + + Iterable returnVal = filter(transform(describer.apply(queries), parser), Predicates.notNull()); + if (logger.isDebugEnabled()) + logger.debug("<< images(%s)", Iterables.size(returnVal)); + return returnVal; + } + + @Override + public String toString() { + return String.format("desribingImages(filter=%s,regions=%s)", filter, regions); + } + +} \ No newline at end of file diff --git a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/reference/AWSEC2Constants.java b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/reference/AWSEC2Constants.java index 4232cb84d3..26c2eace18 100644 --- a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/reference/AWSEC2Constants.java +++ b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/reference/AWSEC2Constants.java @@ -52,6 +52,18 @@ public interface AWSEC2Constants extends EC2Constants { * * @see InstanceType.CC1_4XLARGE */ + @Deprecated public static final String PROPERTY_EC2_CC_AMIs = "jclouds.ec2.cc-amis"; + /** + * expression to find amis that work on the cluster instance type
    + * ex. {@code + * virtualization-type=hvm;architecture=x86_64;owner-id=137112412989,099720109477;hypervisor=xen; + * state=available;image-type=machine;root-device-type=ebs} + * + * @see InstanceType.CC1_4XLARGE + */ + public static final String PROPERTY_EC2_CC_AMI_QUERY = "jclouds.ec2.cc-ami-query"; + public static final String PROPERTY_EC2_CC_REGIONS = "jclouds.ec2.cc-regions"; + public static final String PROPERTY_EC2_AMI_QUERY = "jclouds.ec2.ami-query"; } diff --git a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/AWSEC2PropertiesBuilderTest.java b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/AWSEC2PropertiesBuilderTest.java new file mode 100644 index 0000000000..0499b56772 --- /dev/null +++ b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/AWSEC2PropertiesBuilderTest.java @@ -0,0 +1,68 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.jclouds.aws.ec2; + +import static org.jclouds.aws.ec2.reference.AWSEC2Constants.PROPERTY_EC2_AMI_QUERY; +import static org.jclouds.aws.ec2.reference.AWSEC2Constants.PROPERTY_EC2_CC_AMI_QUERY; +import static org.jclouds.aws.ec2.reference.AWSEC2Constants.PROPERTY_EC2_CC_AMIs; +import static org.jclouds.ec2.reference.EC2Constants.PROPERTY_EC2_AMI_OWNERS; +import static org.testng.Assert.assertEquals; + +import java.util.Properties; + +import org.testng.annotations.Test; + +/** + * @author Adrian Cole + */ +@Test(groups = "unit", testName = "AWSEC2PropertiesBuilderTest") +public class AWSEC2PropertiesBuilderTest { + public void testConvertCCImageSyntax() { + Properties input = new Properties(); + input.setProperty(PROPERTY_EC2_CC_AMIs, "us-east-1/ami-321eed5b,us-east-1/ami-7ea24a17"); + Properties props = new AWSEC2PropertiesBuilder(input).build(); + assertEquals(props.getProperty(PROPERTY_EC2_CC_AMIs), null); + assertEquals(props.getProperty(PROPERTY_EC2_CC_AMI_QUERY), "image-id=ami-321eed5b,ami-7ea24a17"); + } + + public void testConvertImageSyntax() { + Properties input = new Properties(); + input.setProperty(PROPERTY_EC2_AMI_OWNERS, "137112412989,063491364108,099720109477,411009282317"); + Properties props = new AWSEC2PropertiesBuilder(input).build(); + assertEquals(props.getProperty(PROPERTY_EC2_AMI_OWNERS), null); + assertEquals(props.getProperty(PROPERTY_EC2_AMI_QUERY), + "owner-id=137112412989,063491364108,099720109477,411009282317;state=available;image-type=machine"); + } + + public void testConvertImageSyntaxWhenStar() { + Properties input = new Properties(); + input.setProperty(PROPERTY_EC2_AMI_OWNERS, "*"); + Properties props = new AWSEC2PropertiesBuilder(input).build(); + assertEquals(props.getProperty(PROPERTY_EC2_AMI_OWNERS), null); + assertEquals(props.getProperty(PROPERTY_EC2_AMI_QUERY), "state=available;image-type=machine"); + } + + public void testConvertImageSyntaxWhenBlank() { + Properties input = new Properties(); + input.setProperty(PROPERTY_EC2_AMI_OWNERS, ""); + Properties props = new AWSEC2PropertiesBuilder(input).build(); + assertEquals(props.getProperty(PROPERTY_EC2_AMI_OWNERS), null); + assertEquals(props.getProperty(PROPERTY_EC2_AMI_QUERY), ""); + } +} diff --git a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/compute/AWSEC2TemplateBuilderLiveTest.java b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/compute/AWSEC2TemplateBuilderLiveTest.java index 7eb916029d..e77caab364 100644 --- a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/compute/AWSEC2TemplateBuilderLiveTest.java +++ b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/compute/AWSEC2TemplateBuilderLiveTest.java @@ -27,6 +27,7 @@ import java.util.Properties; import java.util.Set; import org.jclouds.aws.domain.Region; +import org.jclouds.aws.ec2.reference.AWSEC2Constants; import org.jclouds.compute.BaseTemplateBuilderLiveTest; import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.ComputeServiceContextFactory; @@ -34,7 +35,6 @@ import org.jclouds.compute.domain.OsFamily; import org.jclouds.compute.domain.OsFamilyVersion64Bit; import org.jclouds.compute.domain.Template; import org.jclouds.ec2.domain.InstanceType; -import org.jclouds.ec2.reference.EC2Constants; import org.jclouds.logging.log4j.config.Log4JLoggingModule; import org.testng.annotations.Test; @@ -81,7 +81,8 @@ public class AWSEC2TemplateBuilderLiveTest extends BaseTemplateBuilderLiveTest { public void testTemplateBuilderM1SMALLWithDescription() { Template template = context.getComputeService().templateBuilder().hardwareId(InstanceType.M1_SMALL) - .osVersionMatches("1[10].[10][04]").imageDescriptionMatches("ubuntu-images").osFamily(OsFamily.UBUNTU).build(); + .osVersionMatches("1[10].[10][04]").imageDescriptionMatches("ubuntu-images").osFamily(OsFamily.UBUNTU) + .build(); assert (template.getImage().getProviderId().startsWith("ami-")) : template; assertEquals(template.getImage().getOperatingSystem().getVersion(), "11.10"); @@ -130,9 +131,10 @@ public class AWSEC2TemplateBuilderLiveTest extends BaseTemplateBuilderLiveTest { @Test public void testFastestTemplateBuilder() throws IOException { - - Template fastestTemplate = context.getComputeService().templateBuilder().fastest().build(); + Template fastestTemplate = context.getComputeService().templateBuilder().fastest().osFamily(OsFamily.AMZN_LINUX) + .build(); assert (fastestTemplate.getImage().getProviderId().startsWith("ami-")) : fastestTemplate; + assertEquals(fastestTemplate.getHardware().getProviderId(), InstanceType.CC1_4XLARGE); assertEquals(fastestTemplate.getImage().getOperatingSystem().getVersion(), "2011.02.1-beta"); assertEquals(fastestTemplate.getImage().getOperatingSystem().is64Bit(), true); assertEquals(fastestTemplate.getImage().getOperatingSystem().getFamily(), OsFamily.AMZN_LINUX); @@ -140,6 +142,17 @@ public class AWSEC2TemplateBuilderLiveTest extends BaseTemplateBuilderLiveTest { assertEquals(fastestTemplate.getLocation().getId(), "us-east-1"); assertEquals(getCores(fastestTemplate.getHardware()), 8.0d); assertEquals(fastestTemplate.getImage().getOperatingSystem().getArch(), "hvm"); + + fastestTemplate = context.getComputeService().templateBuilder().fastest().build(); + assert (fastestTemplate.getImage().getProviderId().startsWith("ami-")) : fastestTemplate; + assertEquals(fastestTemplate.getHardware().getProviderId(), InstanceType.CC1_4XLARGE); + assertEquals(fastestTemplate.getImage().getOperatingSystem().getVersion(), "11.10"); + assertEquals(fastestTemplate.getImage().getOperatingSystem().is64Bit(), true); + assertEquals(fastestTemplate.getImage().getOperatingSystem().getFamily(), OsFamily.UBUNTU); + assertEquals(fastestTemplate.getImage().getUserMetadata().get("rootDeviceType"), "ebs"); + assertEquals(fastestTemplate.getLocation().getId(), "us-east-1"); + assertEquals(getCores(fastestTemplate.getHardware()), 8.0d); + assertEquals(fastestTemplate.getImage().getOperatingSystem().getArch(), "hvm"); } @Test @@ -164,7 +177,8 @@ public class AWSEC2TemplateBuilderLiveTest extends BaseTemplateBuilderLiveTest { try { Properties overrides = setupProperties(); // set owners to nothing - overrides.setProperty(EC2Constants.PROPERTY_EC2_AMI_OWNERS, ""); + overrides.setProperty(AWSEC2Constants.PROPERTY_EC2_AMI_QUERY, ""); + overrides.setProperty(AWSEC2Constants.PROPERTY_EC2_CC_AMI_QUERY, ""); context = new ComputeServiceContextFactory().createContext(provider, ImmutableSet . of(new Log4JLoggingModule()), overrides); diff --git a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/AMIClientLiveTest.java b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/AMIClientLiveTest.java index 08b1fd965c..aa4ec6a140 100644 --- a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/AMIClientLiveTest.java +++ b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/AMIClientLiveTest.java @@ -19,7 +19,8 @@ package org.jclouds.aws.ec2.services; import static com.google.common.base.Preconditions.checkNotNull; -import static org.jclouds.ec2.options.DescribeImagesOptions.Builder.imageIds; +import static org.jclouds.aws.ec2.options.AWSDescribeImagesOptions.Builder.filters; +import static org.jclouds.aws.ec2.options.AWSDescribeImagesOptions.Builder.imageIds; import static org.jclouds.ec2.options.RegisterImageBackedByEbsOptions.Builder.addNewBlockDevice; import static org.jclouds.ec2.options.RegisterImageOptions.Builder.withDescription; import static org.testng.Assert.assertEquals; @@ -30,12 +31,13 @@ import java.util.Properties; import java.util.Set; import org.jclouds.Constants; +import org.jclouds.aws.domain.Region; import org.jclouds.compute.ComputeServiceContextFactory; import org.jclouds.ec2.EC2AsyncClient; import org.jclouds.ec2.EC2Client; import org.jclouds.ec2.domain.Image; -import org.jclouds.ec2.domain.Image.ImageType; import org.jclouds.ec2.domain.RootDeviceType; +import org.jclouds.ec2.domain.Image.ImageType; import org.jclouds.ec2.services.AMIClient; import org.jclouds.logging.log4j.config.Log4JLoggingModule; import org.jclouds.rest.RestContext; @@ -45,6 +47,7 @@ import org.testng.annotations.BeforeGroups; import org.testng.annotations.Test; import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableMultimap; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Iterables; import com.google.common.collect.Sets; @@ -55,7 +58,7 @@ import com.google.inject.Module; * * @author Adrian Cole */ -@Test(groups = "live", sequential = true) +@Test(groups = "live", singleThreaded = true) public class AMIClientLiveTest { private AMIClient client; @@ -99,7 +102,7 @@ public class AMIClientLiveTest { setupCredentials(); Properties overrides = setupProperties(); context = new ComputeServiceContextFactory().createContext(provider, - ImmutableSet. of(new Log4JLoggingModule()), overrides).getProviderSpecificContext(); + ImmutableSet. of(new Log4JLoggingModule()), overrides).getProviderSpecificContext(); client = context.getApi().getAMIServices(); } @@ -114,13 +117,13 @@ public class AMIClientLiveTest { public void testDescribeImages() { for (String region : context.getApi().getAvailabilityZoneAndRegionServices().describeRegions().keySet()) { - Set allResults = Sets.newLinkedHashSet(client.describeImagesInRegion(region)); + Set allResults = client.describeImagesInRegion(region); assertNotNull(allResults); assert allResults.size() >= 2 : allResults.size(); - Iterator iterator = allResults.iterator(); + Iterator iterator = allResults.iterator(); String id1 = iterator.next().getId(); String id2 = iterator.next().getId(); - Set twoResults = Sets.newLinkedHashSet(client.describeImagesInRegion(region, imageIds(id1, id2))); + Set twoResults = client.describeImagesInRegion(region, imageIds(id1, id2)); assertNotNull(twoResults); assertEquals(twoResults.size(), 2); iterator = twoResults.iterator(); @@ -129,12 +132,27 @@ public class AMIClientLiveTest { } } + public void testDescribeImagesCC() { + Set twoResults = client.describeImagesInRegion(Region.US_EAST_1, filters( + ImmutableMultimap. builder()// + .put("virtualization-type", "hvm")// + .put("architecture", "x86_64")// + .putAll("owner-id", ImmutableSet. of("137112412989", "099720109477"))// + .put("hypervisor", "xen")// + .put("state", "available")// + .put("image-type", "machine")// + .put("root-device-type", "ebs")// + .build()).ownedBy("137112412989", "099720109477")); + assertNotNull(twoResults); + assertEquals(twoResults.size(), 26); + } + @Test(enabled = false) public void testRegisterImageFromManifest() { String imageRegisteredId = client.registerImageFromManifestInRegion(null, "jcloudstest1", DEFAULT_MANIFEST); imagesToDeregister.add(imageRegisteredId); Image imageRegisteredFromManifest = Iterables.getOnlyElement(client.describeImagesInRegion(null, - imageIds(imageRegisteredId))); + imageIds(imageRegisteredId))); assertEquals(imageRegisteredFromManifest.getName(), "jcloudstest1"); assertEquals(imageRegisteredFromManifest.getImageLocation(), DEFAULT_MANIFEST); assertEquals(imageRegisteredFromManifest.getImageType(), ImageType.MACHINE); @@ -145,10 +163,10 @@ public class AMIClientLiveTest { @Test(enabled = false) public void testRegisterImageFromManifestOptions() { String imageRegisteredWithOptionsId = client.registerImageFromManifestInRegion(null, "jcloudstest2", - DEFAULT_MANIFEST, withDescription("adrian")); + DEFAULT_MANIFEST, withDescription("adrian")); imagesToDeregister.add(imageRegisteredWithOptionsId); Image imageRegisteredFromManifestWithOptions = Iterables.getOnlyElement(client.describeImagesInRegion(null, - imageIds(imageRegisteredWithOptionsId))); + imageIds(imageRegisteredWithOptionsId))); assertEquals(imageRegisteredFromManifestWithOptions.getName(), "jcloudstest2"); assertEquals(imageRegisteredFromManifestWithOptions.getImageLocation(), DEFAULT_MANIFEST); assertEquals(imageRegisteredFromManifestWithOptions.getImageType(), ImageType.MACHINE); @@ -163,7 +181,7 @@ public class AMIClientLiveTest { String imageRegisteredId = client.registerUnixImageBackedByEbsInRegion(null, "jcloudstest1", DEFAULT_MANIFEST); imagesToDeregister.add(imageRegisteredId); Image imageRegistered = Iterables - .getOnlyElement(client.describeImagesInRegion(null, imageIds(imageRegisteredId))); + .getOnlyElement(client.describeImagesInRegion(null, imageIds(imageRegisteredId))); assertEquals(imageRegistered.getName(), "jcloudstest1"); assertEquals(imageRegistered.getImageType(), ImageType.MACHINE); assertEquals(imageRegistered.getRootDeviceType(), RootDeviceType.EBS); @@ -174,19 +192,18 @@ public class AMIClientLiveTest { // awaiting EBS functionality to be added to jclouds public void testRegisterImageBackedByEBSOptions() { String imageRegisteredWithOptionsId = client.registerUnixImageBackedByEbsInRegion(null, "jcloudstest2", - DEFAULT_SNAPSHOT, addNewBlockDevice("/dev/sda2", "myvirtual", 1).withDescription("adrian")); + DEFAULT_SNAPSHOT, addNewBlockDevice("/dev/sda2", "myvirtual", 1).withDescription("adrian")); imagesToDeregister.add(imageRegisteredWithOptionsId); Image imageRegisteredWithOptions = Iterables.getOnlyElement(client.describeImagesInRegion(null, - imageIds(imageRegisteredWithOptionsId))); + imageIds(imageRegisteredWithOptionsId))); assertEquals(imageRegisteredWithOptions.getName(), "jcloudstest2"); assertEquals(imageRegisteredWithOptions.getImageType(), ImageType.MACHINE); assertEquals(imageRegisteredWithOptions.getRootDeviceType(), RootDeviceType.EBS); assertEquals(imageRegisteredWithOptions.getRootDeviceName(), "/dev/sda1"); assertEquals(imageRegisteredWithOptions.getDescription(), "adrian"); - assertEquals( - imageRegisteredWithOptions.getEbsBlockDevices().entrySet(), - ImmutableMap.of("/dev/sda1", new Image.EbsBlockDevice("/dev/sda1", 30, true), "/dev/sda2", - new Image.EbsBlockDevice("/dev/sda2", 1, true)).entrySet()); + assertEquals(imageRegisteredWithOptions.getEbsBlockDevices().entrySet(), ImmutableMap.of("/dev/sda1", + new Image.EbsBlockDevice("/dev/sda1", 30, true), "/dev/sda2", + new Image.EbsBlockDevice("/dev/sda2", 1, true)).entrySet()); } @Test(enabled = false) diff --git a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/AWSAMIAsyncClientTest.java b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/AWSAMIAsyncClientTest.java index d68411ecb3..1ab9d7e008 100644 --- a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/AWSAMIAsyncClientTest.java +++ b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/AWSAMIAsyncClientTest.java @@ -18,7 +18,7 @@ */ package org.jclouds.aws.ec2.services; -import static org.jclouds.ec2.options.DescribeImagesOptions.Builder.executableBy; +import static org.jclouds.aws.ec2.options.AWSDescribeImagesOptions.Builder.filters; import java.io.IOException; import java.lang.reflect.Array; @@ -41,6 +41,7 @@ import org.jclouds.rest.internal.RestAnnotationProcessor; import org.testng.annotations.Test; import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; import com.google.inject.TypeLiteral; /** @@ -115,16 +116,18 @@ public class AWSAMIAsyncClientTest extends BaseAWSEC2AsyncClientTest sizes = context.getComputeService().listHardwareProfiles(); - assert any(sizes, new Predicate() { - - @Override - public boolean apply(Hardware arg0) { - return arg0.getProviderId().equals(InstanceType.CC1_4XLARGE); - } - - }) : sizes; - Set images = context.getComputeService().listImages(); - assert any(images, new Predicate() { - - @Override - public boolean apply(Image arg0) { - return arg0.getId().equals("us-east-1/ami-7ea24a17"); - } - - }) : images; - - Template template = context.getComputeService().templateBuilder().fastest().build(); + Template template = context.getComputeService().templateBuilder().fastest().osVersionMatches("11.04").build(); assert template != null : "The returned template was null, but it should have a value."; assertEquals(template.getHardware().getProviderId(), InstanceType.CC1_4XLARGE); - assertEquals(template.getImage().getId(), "us-east-1/ami-321eed5b"); + assertEquals(template.getImage().getUserMetadata().get("rootDeviceType"), "ebs"); + assertEquals(template.getImage().getUserMetadata().get("virtualizationType"), "hvm"); + assertEquals(template.getImage().getUserMetadata().get("hypervisor"), "xen"); template.getOptions().overrideLoginCredentialWith(keyPair.get("private")) .authorizePublicKey(keyPair.get("public")).runScript(buildScript(template.getImage().getOperatingSystem())); From 5f54110a47db423536807a63399e8492bb735db7 Mon Sep 17 00:00:00 2001 From: Adrian Cole Date: Tue, 12 Jul 2011 00:16:02 -0700 Subject: [PATCH 124/264] Issue 623:clean up exception messages when templateBuilder fails to match an image --- .../internal/EC2TemplateBuilderImpl.java | 4 +- .../internal/EC2TemplateBuilderImplTest.java | 2 +- .../domain/internal/TemplateBuilderImpl.java | 78 +++++++++++++------ .../StubTemplateBuilderIntegrationTest.java | 1 + .../internal/TemplateBuilderImplTest.java | 44 +++++++++++ 5 files changed, 103 insertions(+), 26 deletions(-) diff --git a/apis/ec2/src/main/java/org/jclouds/ec2/compute/internal/EC2TemplateBuilderImpl.java b/apis/ec2/src/main/java/org/jclouds/ec2/compute/internal/EC2TemplateBuilderImpl.java index 413a8fe19d..e77527f2c1 100644 --- a/apis/ec2/src/main/java/org/jclouds/ec2/compute/internal/EC2TemplateBuilderImpl.java +++ b/apis/ec2/src/main/java/org/jclouds/ec2/compute/internal/EC2TemplateBuilderImpl.java @@ -69,9 +69,9 @@ public class EC2TemplateBuilderImpl extends TemplateBuilderImpl { try { return imageMap.get(key); } catch (NullPointerException nex) { - throw new NoSuchElementException(String.format("image %s/%s not found", key.getRegion(), key.getName())); + throw new NoSuchElementException(String.format("imageId(%s/%s) not found", key.getRegion(), key.getName())); } catch (ComputationException nex) { - throw new NoSuchElementException(String.format("image %s/%s not found", key.getRegion(), key.getName())); + throw new NoSuchElementException(String.format("imageId(%s/%s) not found", key.getRegion(), key.getName())); } } return null; diff --git a/apis/ec2/src/test/java/org/jclouds/ec2/compute/internal/EC2TemplateBuilderImplTest.java b/apis/ec2/src/test/java/org/jclouds/ec2/compute/internal/EC2TemplateBuilderImplTest.java index 8b05766f1d..a58441ed1e 100644 --- a/apis/ec2/src/test/java/org/jclouds/ec2/compute/internal/EC2TemplateBuilderImplTest.java +++ b/apis/ec2/src/test/java/org/jclouds/ec2/compute/internal/EC2TemplateBuilderImplTest.java @@ -57,7 +57,7 @@ import com.google.common.collect.Sets; * * @author Adrian Cole */ -@Test(groups = "unit", sequential = true) +@Test(groups = "unit", singleThreaded = true) public class EC2TemplateBuilderImplTest extends TemplateBuilderImplTest { @Override diff --git a/compute/src/main/java/org/jclouds/compute/domain/internal/TemplateBuilderImpl.java b/compute/src/main/java/org/jclouds/compute/domain/internal/TemplateBuilderImpl.java index 4c9c44949a..40d23b0a51 100644 --- a/compute/src/main/java/org/jclouds/compute/domain/internal/TemplateBuilderImpl.java +++ b/compute/src/main/java/org/jclouds/compute/domain/internal/TemplateBuilderImpl.java @@ -21,11 +21,14 @@ package org.jclouds.compute.domain.internal; import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Predicates.and; import static com.google.common.collect.Iterables.filter; +import static com.google.common.collect.Iterables.find; +import static com.google.common.collect.Iterables.size; +import static com.google.common.collect.Iterables.transform; import static com.google.common.collect.Lists.newArrayList; import static org.jclouds.compute.util.ComputeServiceUtils.getCores; import static org.jclouds.compute.util.ComputeServiceUtils.getCoresAndSpeed; import static org.jclouds.compute.util.ComputeServiceUtils.getSpace; - +import static java.lang.String.format; import java.util.List; import java.util.NoSuchElementException; import java.util.Set; @@ -50,6 +53,7 @@ import org.jclouds.logging.Logger; import org.jclouds.util.Lists2; import com.google.common.annotations.VisibleForTesting; +import com.google.common.base.Function; import com.google.common.base.Predicate; import com.google.common.base.Predicates; import com.google.common.base.Supplier; @@ -145,7 +149,7 @@ public class TemplateBuilderImpl implements TemplateBuilder { @Override public String toString() { - return "location(" + location + ")"; + return location == null ? "anyLocation()" : "locationEqualsOrChildOf(" + location.getId() + ")"; } }; @@ -500,7 +504,7 @@ public class TemplateBuilderImpl implements TemplateBuilder { public TemplateBuilder locationId(final String locationId) { Set locations = this.locations.get(); try { - this.location = Iterables.find(locations, new Predicate() { + this.location = find(locations, new Predicate() { @Override public boolean apply(Location input) { @@ -514,7 +518,7 @@ public class TemplateBuilderImpl implements TemplateBuilder { }); } catch (NoSuchElementException e) { - throw new NoSuchElementException(String.format("location id %s not found in: %s", locationId, locations)); + throw new NoSuchElementException(format("location id %s not found in: %s", locationId, locations)); } return this; } @@ -528,6 +532,15 @@ public class TemplateBuilderImpl implements TemplateBuilder { return this; } + private static final Function imageToId = new Function() { + + @Override + public String apply(Image arg0) { + return arg0.getId(); + } + + }; + /** * {@inheritDoc} */ @@ -547,9 +560,14 @@ public class TemplateBuilderImpl implements TemplateBuilder { Set images = getImages(); Predicate imagePredicate = buildImagePredicate(); Iterable supportedImages = filter(images, buildImagePredicate()); - if (Iterables.size(supportedImages) == 0) - throw new NoSuchElementException(String.format( - "no image matched predicate %s images that didn't match below:\n%s", imagePredicate, images)); + if (size(supportedImages) == 0) { + if (imagePredicate == idPredicate) { + throw new NoSuchElementException(format("%s not found", idPredicate)); + } else { + throwNoSuchElementExceptionAfterLoggingImageIds(format("no image matched predicate: %s", imagePredicate), + images); + } + } Hardware hardware = resolveSize(hardwareSorter(), supportedImages); Image image = resolveImage(hardware, supportedImages); logger.debug("<< matched image(%s)", image); @@ -557,6 +575,13 @@ public class TemplateBuilderImpl implements TemplateBuilder { return new TemplateImpl(image, hardware, location, options); } + protected void throwNoSuchElementExceptionAfterLoggingImageIds(String message, Iterable images) { + NoSuchElementException exception = new NoSuchElementException(message); + if (logger.isTraceEnabled()) + logger.warn(exception, "image ids that didn't match: %s", transform(images, imageToId)); + throw exception; + } + protected Hardware resolveSize(Ordering hardwareOrdering, final Iterable images) { Set hardwarel = hardwares.get(); Hardware hardware; @@ -583,8 +608,11 @@ public class TemplateBuilderImpl implements TemplateBuilder { }); hardware = hardwareOrdering.max(filter(hardwaresThatAreCompatibleWithOurImages, hardwarePredicate)); } catch (NoSuchElementException exception) { - throw new NoSuchElementException("hardware don't support any images: " + toString() + "\n" + hardwarel - + "\n" + images); + String message = format("no hardware profiles support images matching params: %s", toString()); + exception = new NoSuchElementException(message); + if (logger.isTraceEnabled()) + logger.warn(exception, "hardware profiles %s\nimage ids %s", hardwarel, transform(images, imageToId)); + throw exception; } logger.debug("<< matched hardware(%s)", hardware); return hardware; @@ -622,13 +650,16 @@ public class TemplateBuilderImpl implements TemplateBuilder { try { Iterable matchingImages = filter(supportedImages, imagePredicate); if (logger.isTraceEnabled()) - logger.trace("<< matched images(%s)", matchingImages); + logger.trace("<< matched images(%s)", transform(matchingImages, imageToId)); List maxImages = Lists2.multiMax(DEFAULT_IMAGE_ORDERING, matchingImages); if (logger.isTraceEnabled()) - logger.trace("<< best images(%s)", maxImages); + logger.trace("<< best images(%s)", transform(maxImages, imageToId)); return maxImages.get(maxImages.size() - 1); } catch (NoSuchElementException exception) { - throw new NoSuchElementException("image didn't match: " + toString() + "\n" + supportedImages); + throwNoSuchElementExceptionAfterLoggingImageIds(format("no image matched params: %s", toString()), + supportedImages); + assert false; + return null; } } @@ -651,7 +682,7 @@ public class TemplateBuilderImpl implements TemplateBuilder { @Override public String toString() { - return "location(" + location + ")"; + return locationPredicate.toString(); } }); @@ -668,19 +699,20 @@ public class TemplateBuilderImpl implements TemplateBuilder { osPredicates.add(os64BitPredicate); if (osArch != null) osPredicates.add(osArchPredicate); - predicates.add(new Predicate() { + if (osPredicates.size() > 0) + predicates.add(new Predicate() { - @Override - public boolean apply(Image input) { - return Predicates.and(osPredicates).apply(input.getOperatingSystem()); - } + @Override + public boolean apply(Image input) { + return and(osPredicates).apply(input.getOperatingSystem()); + } - @Override - public String toString() { - return Predicates.and(osPredicates).toString(); - } + @Override + public String toString() { + return and(osPredicates).toString(); + } - }); + }); if (imageVersion != null) predicates.add(imageVersionPredicate); if (imageName != null) diff --git a/compute/src/test/java/org/jclouds/compute/StubTemplateBuilderIntegrationTest.java b/compute/src/test/java/org/jclouds/compute/StubTemplateBuilderIntegrationTest.java index efd3a6f0ad..f57fb5ae1a 100644 --- a/compute/src/test/java/org/jclouds/compute/StubTemplateBuilderIntegrationTest.java +++ b/compute/src/test/java/org/jclouds/compute/StubTemplateBuilderIntegrationTest.java @@ -46,4 +46,5 @@ public class StubTemplateBuilderIntegrationTest extends BaseTemplateBuilderLiveT protected Set getIso3166Codes() { return ImmutableSet. of(); } + } \ No newline at end of file diff --git a/compute/src/test/java/org/jclouds/compute/domain/internal/TemplateBuilderImplTest.java b/compute/src/test/java/org/jclouds/compute/domain/internal/TemplateBuilderImplTest.java index 0eee4197f7..641a0d1c37 100644 --- a/compute/src/test/java/org/jclouds/compute/domain/internal/TemplateBuilderImplTest.java +++ b/compute/src/test/java/org/jclouds/compute/domain/internal/TemplateBuilderImplTest.java @@ -274,6 +274,10 @@ public class TemplateBuilderImplTest { template.imageId("notImageId").build(); assert false; } catch (NoSuchElementException e) { + // make sure big data is not in the exception message + assertEquals( + e.getMessage(), + "no hardware profiles support images matching params: [biggest=false, fastest=false, imageName=null, imageDescription=null, imageId=notImageId, imageVersion=null, location=EasyMock for interface org.jclouds.domain.Location, minCores=0.0, minRam=0, osFamily=null, osName=null, osDescription=null, osVersion=null, osArch=null, os64Bit=false, hardwareId=null]"); verify(image); verify(os); verify(defaultTemplate); @@ -523,7 +527,47 @@ public class TemplateBuilderImplTest { template.imageId("region/ami").build(); assert false; } catch (NoSuchElementException e) { + // make sure big data is not in the exception message + assertEquals(e.getMessage(), "imageId(region/ami) not found"); + } + verify(defaultOptions); + verify(defaultLocation); + verify(optionsProvider); + verify(templateBuilderProvider); + } + + @SuppressWarnings("unchecked") + @Test + public void testDefaultLocationWithUnmatchedPredicateExceptionMessage() { + Supplier> locations = Suppliers.> ofInstance(ImmutableSet + . of()); + Supplier> images = Suppliers.> ofInstance(ImmutableSet. of()); + Supplier> hardwares = Suppliers.> ofInstance(ImmutableSet + . of()); + Location defaultLocation = createMock(Location.class); + Provider optionsProvider = createMock(Provider.class); + Provider templateBuilderProvider = createMock(Provider.class); + TemplateOptions defaultOptions = createMock(TemplateOptions.class); + + expect(defaultLocation.getId()).andReturn("us-east-1"); + + expect(optionsProvider.get()).andReturn(defaultOptions); + + replay(defaultOptions); + replay(defaultLocation); + replay(optionsProvider); + replay(templateBuilderProvider); + + TemplateBuilderImpl template = createTemplateBuilder(null, locations, images, hardwares, defaultLocation, + optionsProvider, templateBuilderProvider); + + try { + template.imageDescriptionMatches("region/ami").build(); + assert false; + } catch (NoSuchElementException e) { + // make sure big data is not in the exception message + assertEquals(e.getMessage(), "no image matched predicate: And(locationEqualsOrChildOf(us-east-1),imageDescription(region/ami))"); } verify(defaultOptions); From d9b9c61ce6b7f6af32f71ad95f19ae639446a130 Mon Sep 17 00:00:00 2001 From: spasam Date: Tue, 12 Jul 2011 11:21:20 -0400 Subject: [PATCH 125/264] Implented vApp tag support for Terremark Enterprise. Also added configurable exponential delay between automatic retries. --- .../vcloud/domain/VCloudExpressVApp.java | 2 + .../internal/VCloudExpressVAppImpl.java | 24 ++++++- .../vcloud/xml/VCloudExpressVAppHandler.java | 11 ++- core/src/main/java/org/jclouds/Constants.java | 9 +++ .../java/org/jclouds/PropertiesBuilder.java | 9 +++ .../jclouds/concurrent/FutureIterables.java | 8 ++- .../handlers/BackoffLimitedRetryHandler.java | 6 +- providers/trmk-ecloud/pom.xml | 2 +- .../terremark/TerremarkECloudAsyncClient.java | 12 ++++ .../terremark/TerremarkECloudClient.java | 8 +++ .../terremark/TerremarkECloudMediaType.java | 19 ++++-- .../TerremarkECloudPropertiesBuilder.java | 4 +- .../TerremarkECloudAsyncClientTest.java | 28 ++++++-- .../src/test/resources/catalog-ecloud.xml | 68 +++++++++---------- 14 files changed, 155 insertions(+), 55 deletions(-) diff --git a/apis/vcloudexpress/src/main/java/org/jclouds/vcloud/domain/VCloudExpressVApp.java b/apis/vcloudexpress/src/main/java/org/jclouds/vcloud/domain/VCloudExpressVApp.java index c06817403f..1f33b96bd5 100644 --- a/apis/vcloudexpress/src/main/java/org/jclouds/vcloud/domain/VCloudExpressVApp.java +++ b/apis/vcloudexpress/src/main/java/org/jclouds/vcloud/domain/VCloudExpressVApp.java @@ -40,6 +40,8 @@ import com.google.inject.ImplementedBy; public interface VCloudExpressVApp extends ReferenceType { ReferenceType getVDC(); + Set getExtendedInfo(); + Status getStatus(); Long getSize(); diff --git a/apis/vcloudexpress/src/main/java/org/jclouds/vcloud/domain/internal/VCloudExpressVAppImpl.java b/apis/vcloudexpress/src/main/java/org/jclouds/vcloud/domain/internal/VCloudExpressVAppImpl.java index afbcbb51e0..4e4a7c6b7f 100644 --- a/apis/vcloudexpress/src/main/java/org/jclouds/vcloud/domain/internal/VCloudExpressVAppImpl.java +++ b/apis/vcloudexpress/src/main/java/org/jclouds/vcloud/domain/internal/VCloudExpressVAppImpl.java @@ -21,6 +21,7 @@ package org.jclouds.vcloud.domain.internal; import static com.google.common.base.Preconditions.checkNotNull; import java.net.URI; +import java.util.HashSet; import java.util.Set; import org.jclouds.cim.ResourceAllocationSettingData; @@ -41,6 +42,7 @@ public class VCloudExpressVAppImpl implements VCloudExpressVApp { private final String name; private final URI href; private final ReferenceType vDC; + private final Set extendedInfo; private final Status status; private final Long size; private final ListMultimap networkToAddresses; @@ -55,6 +57,14 @@ public class VCloudExpressVAppImpl implements VCloudExpressVApp { public VCloudExpressVAppImpl(String name, URI href, Status status, Long size, ReferenceType vDC, ListMultimap networkToAddresses, Integer osType, String operatingSystemDescription, VirtualSystemSettingData system, Set resourceAllocations) { + this(name, href, status, size, vDC, networkToAddresses, osType, operatingSystemDescription, system, + resourceAllocations, new HashSet()); + } + + public VCloudExpressVAppImpl(String name, URI href, Status status, Long size, ReferenceType vDC, + ListMultimap networkToAddresses, Integer osType, String operatingSystemDescription, + VirtualSystemSettingData system, Set resourceAllocations, + Set extendedInfo) { this.name = checkNotNull(name, "name"); this.href = checkNotNull(href, "href"); this.status = checkNotNull(status, "status"); @@ -65,6 +75,7 @@ public class VCloudExpressVAppImpl implements VCloudExpressVApp { this.operatingSystemDescription = operatingSystemDescription; this.system = system; this.resourceAllocations = checkNotNull(resourceAllocations, "resourceAllocations"); + this.extendedInfo = extendedInfo; } @Override @@ -102,6 +113,11 @@ public class VCloudExpressVAppImpl implements VCloudExpressVApp { return vDC; } + @Override + public Set getExtendedInfo() { + return extendedInfo; + } + @Override public int hashCode() { final int prime = 31; @@ -116,6 +132,7 @@ public class VCloudExpressVAppImpl implements VCloudExpressVApp { result = prime * result + ((status == null) ? 0 : status.hashCode()); result = prime * result + ((system == null) ? 0 : system.hashCode()); result = prime * result + ((vDC == null) ? 0 : vDC.hashCode()); + result = prime * result + ((extendedInfo == null) ? 0 : extendedInfo.hashCode()); return result; } @@ -178,6 +195,11 @@ public class VCloudExpressVAppImpl implements VCloudExpressVApp { return false; } else if (!vDC.equals(other.vDC)) return false; + if (extendedInfo == null) { + if (other.extendedInfo != null) + return false; + } else if (!extendedInfo.equals(other.extendedInfo)) + return false; return true; } @@ -201,7 +223,7 @@ public class VCloudExpressVAppImpl implements VCloudExpressVApp { return "[href=" + href + ", name=" + name + ", networkToAddresses=" + networkToAddresses + ", osType=" + osType + ", operatingSystemDescription=" + operatingSystemDescription + ", resourceAllocationByType=" + resourceAllocations + ", size=" + size + ", status=" + status + ", system=" + system + ", vDC=" + vDC - + "]"; + + ", extendedInfo=" + extendedInfo + "]"; } @Override diff --git a/apis/vcloudexpress/src/main/java/org/jclouds/vcloud/xml/VCloudExpressVAppHandler.java b/apis/vcloudexpress/src/main/java/org/jclouds/vcloud/xml/VCloudExpressVAppHandler.java index 0f9a672496..341ffbe93b 100644 --- a/apis/vcloudexpress/src/main/java/org/jclouds/vcloud/xml/VCloudExpressVAppHandler.java +++ b/apis/vcloudexpress/src/main/java/org/jclouds/vcloud/xml/VCloudExpressVAppHandler.java @@ -79,10 +79,11 @@ public class VCloudExpressVAppHandler extends ParseSax.HandlerWithResult extendedInfo = Sets.newLinkedHashSet(); public VCloudExpressVApp getResult() { return new VCloudExpressVAppImpl(name, location, status, size, vDC, networkToAddresses, osType, - operatingSystemDescription, system, allocations); + operatingSystemDescription, system, allocations, extendedInfo); } public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException { @@ -99,8 +100,12 @@ public class VCloudExpressVAppHandler extends ParseSax.HandlerWithResult + * Commands are retried, if the problem on the server side was a resolvable conflict. However, + * the maximum tries of a single command is bounded. If {@link #PROPERTY_MAX_RETRIES} is greater + * than zero, this property is used to determine the start delay. The delay is based on exponential + * backoff algorithm. Default value for this property is 50 milliseconds. + */ + public static final String PROPERTY_RETRY_DELAY_START = "jclouds.retries-delay-start"; /** * Integer property. *

    diff --git a/core/src/main/java/org/jclouds/PropertiesBuilder.java b/core/src/main/java/org/jclouds/PropertiesBuilder.java index c575e6dbd8..a29f34afd8 100644 --- a/core/src/main/java/org/jclouds/PropertiesBuilder.java +++ b/core/src/main/java/org/jclouds/PropertiesBuilder.java @@ -38,6 +38,7 @@ import static org.jclouds.Constants.PROPERTY_PROXY_PORT; import static org.jclouds.Constants.PROPERTY_PROXY_SYSTEM; import static org.jclouds.Constants.PROPERTY_PROXY_USER; import static org.jclouds.Constants.PROPERTY_RELAX_HOSTNAME; +import static org.jclouds.Constants.PROPERTY_RETRY_DELAY_START; import static org.jclouds.Constants.PROPERTY_SESSION_INTERVAL; import static org.jclouds.Constants.PROPERTY_SO_TIMEOUT; import static org.jclouds.Constants.PROPERTY_TRUST_ALL_CERTS; @@ -137,6 +138,14 @@ public class PropertiesBuilder { return this; } + /** + * @see org.jclouds.Constants.PROPERTY_RETRY_DELAY_START + */ + public PropertiesBuilder withRetriesDelayStart(long delayStart) { + properties.setProperty(PROPERTY_RETRY_DELAY_START, Long.toString(delayStart)); + return this; + } + /** * @see org.jclouds.Constants.PROPERTY_MAX_REDIRECTS */ diff --git a/core/src/main/java/org/jclouds/concurrent/FutureIterables.java b/core/src/main/java/org/jclouds/concurrent/FutureIterables.java index 2540950acd..d1976d4485 100644 --- a/core/src/main/java/org/jclouds/concurrent/FutureIterables.java +++ b/core/src/main/java/org/jclouds/concurrent/FutureIterables.java @@ -59,6 +59,10 @@ public class FutureIterables { @Named(Constants.PROPERTY_MAX_RETRIES) private static int maxRetries = 5; + @Inject(optional = true) + @Named(Constants.PROPERTY_RETRY_DELAY_START) + private static long delayStart = 50L; + @Inject(optional = true) private static BackoffLimitedRetryHandler retryHandler = BackoffLimitedRetryHandler.INSTANCE; @@ -91,8 +95,8 @@ public class FutureIterables { exceptions = awaitCompletion(responses, exec, maxTime, logger, logPrefix); if (exceptions.size() > 0) { fromIterable = exceptions.keySet(); - retryHandler.imposeBackoffExponentialDelay(i + 1, String.format("error %s: %s: %s", logPrefix, - fromIterable, exceptions)); + retryHandler.imposeBackoffExponentialDelay(delayStart, 2, i + 1, maxRetries, + String.format("error %s: %s: %s", logPrefix, fromIterable, exceptions)); } else { break; } diff --git a/core/src/main/java/org/jclouds/http/handlers/BackoffLimitedRetryHandler.java b/core/src/main/java/org/jclouds/http/handlers/BackoffLimitedRetryHandler.java index 606dc0e8db..51940d1808 100644 --- a/core/src/main/java/org/jclouds/http/handlers/BackoffLimitedRetryHandler.java +++ b/core/src/main/java/org/jclouds/http/handlers/BackoffLimitedRetryHandler.java @@ -86,6 +86,10 @@ public class BackoffLimitedRetryHandler implements HttpRetryHandler, IOException @Named(Constants.PROPERTY_MAX_RETRIES) private int retryCountLimit = 5; + @Inject(optional = true) + @Named(Constants.PROPERTY_RETRY_DELAY_START) + private long delayStart = 50L; + @Resource protected Logger logger = Logger.NULL; @@ -115,7 +119,7 @@ public class BackoffLimitedRetryHandler implements HttpRetryHandler, IOException } public void imposeBackoffExponentialDelay(int failureCount, String commandDescription) { - imposeBackoffExponentialDelay(50L, 2, failureCount, retryCountLimit, commandDescription); + imposeBackoffExponentialDelay(delayStart, 2, failureCount, retryCountLimit, commandDescription); } public void imposeBackoffExponentialDelay(long period, int pow, int failureCount, int max, String commandDescription) { diff --git a/providers/trmk-ecloud/pom.xml b/providers/trmk-ecloud/pom.xml index b4bd4af5ab..84fdebe991 100644 --- a/providers/trmk-ecloud/pom.xml +++ b/providers/trmk-ecloud/pom.xml @@ -36,7 +36,7 @@ https://services.enterprisecloud.terremark.com/api - 0.8b-ext2.7 + 0.8b-ext2.8 FIXME FIXME diff --git a/providers/trmk-ecloud/src/main/java/org/jclouds/vcloud/terremark/TerremarkECloudAsyncClient.java b/providers/trmk-ecloud/src/main/java/org/jclouds/vcloud/terremark/TerremarkECloudAsyncClient.java index f1c636f6c8..76ddf1c302 100644 --- a/providers/trmk-ecloud/src/main/java/org/jclouds/vcloud/terremark/TerremarkECloudAsyncClient.java +++ b/providers/trmk-ecloud/src/main/java/org/jclouds/vcloud/terremark/TerremarkECloudAsyncClient.java @@ -25,6 +25,7 @@ import static org.jclouds.vcloud.terremark.TerremarkECloudMediaType.INTERNETSERV import static org.jclouds.vcloud.terremark.TerremarkECloudMediaType.IPADDRESS_LIST_XML; import static org.jclouds.vcloud.terremark.TerremarkECloudMediaType.KEYSLIST_XML; import static org.jclouds.vcloud.terremark.TerremarkECloudMediaType.PUBLICIP_XML; +import static org.jclouds.vcloud.terremark.TerremarkECloudMediaType.VAPPEXTINFO_XML; import java.net.URI; import java.util.Set; @@ -55,6 +56,7 @@ import org.jclouds.vcloud.terremark.domain.KeyPair; import org.jclouds.vcloud.terremark.domain.Protocol; import org.jclouds.vcloud.terremark.domain.PublicIpAddress; import org.jclouds.vcloud.terremark.domain.TerremarkNetwork; +import org.jclouds.vcloud.terremark.domain.VAppExtendedInfo; import org.jclouds.vcloud.terremark.domain.TerremarkOrgNetwork; import org.jclouds.vcloud.terremark.functions.OrgURIToKeysListEndpoint; import org.jclouds.vcloud.terremark.functions.VDCURIToInternetServicesEndpoint; @@ -69,6 +71,7 @@ import org.jclouds.vcloud.terremark.xml.KeyPairsHandler; import org.jclouds.vcloud.terremark.xml.PublicIpAddressesHandler; import org.jclouds.vcloud.terremark.xml.TerremarkNetworkHandler; import org.jclouds.vcloud.terremark.xml.TerremarkOrgNetworkFromTerremarkVCloudExpressNetworkHandler; +import org.jclouds.vcloud.terremark.xml.VAppExtendedInfoHandler; import com.google.common.util.concurrent.ListenableFuture; @@ -250,4 +253,13 @@ public interface TerremarkECloudAsyncClient extends TerremarkVCloudAsyncClient { @XMLResponseParser(IpAddressesHandler.class) @ExceptionParser(ReturnEmptySetOnNotFoundOr404.class) ListenableFuture> getIpAddresses(@EndpointParam URI network); + + /** + * @see TerremarkVCloudExpressClient#getInternetService + */ + @GET + @Consumes(VAPPEXTINFO_XML) + @XMLResponseParser(VAppExtendedInfoHandler.class) + @ExceptionParser(ReturnNullOnNotFoundOr404.class) + ListenableFuture getVAppExtendedInfo(@EndpointParam URI href); } diff --git a/providers/trmk-ecloud/src/main/java/org/jclouds/vcloud/terremark/TerremarkECloudClient.java b/providers/trmk-ecloud/src/main/java/org/jclouds/vcloud/terremark/TerremarkECloudClient.java index e57e145aef..cef87694cc 100644 --- a/providers/trmk-ecloud/src/main/java/org/jclouds/vcloud/terremark/TerremarkECloudClient.java +++ b/providers/trmk-ecloud/src/main/java/org/jclouds/vcloud/terremark/TerremarkECloudClient.java @@ -29,6 +29,7 @@ import org.jclouds.vcloud.terremark.domain.IpAddress; import org.jclouds.vcloud.terremark.domain.PublicIpAddress; import org.jclouds.vcloud.terremark.domain.TerremarkNetwork; import org.jclouds.vcloud.terremark.domain.TerremarkOrgNetwork; +import org.jclouds.vcloud.terremark.domain.VAppExtendedInfo; /** * Provides access to VCloud resources via their REST API. @@ -58,4 +59,11 @@ public interface TerremarkECloudClient extends TerremarkVCloudClient { Set getIpAddresses(URI network); + /** + * Returns extended information for the vApp. + * + * @param vApp The URI at which the vApp information is available. + * @return Extended vApp information like tags, long name, network adapter information. + */ + VAppExtendedInfo getVAppExtendedInfo(URI href); } diff --git a/providers/trmk-ecloud/src/main/java/org/jclouds/vcloud/terremark/TerremarkECloudMediaType.java b/providers/trmk-ecloud/src/main/java/org/jclouds/vcloud/terremark/TerremarkECloudMediaType.java index 12aff66d17..95f527b3e3 100644 --- a/providers/trmk-ecloud/src/main/java/org/jclouds/vcloud/terremark/TerremarkECloudMediaType.java +++ b/providers/trmk-ecloud/src/main/java/org/jclouds/vcloud/terremark/TerremarkECloudMediaType.java @@ -22,7 +22,7 @@ import javax.ws.rs.core.MediaType; /** * Resource Types used in Terremark eCloud - * + * * @see MediaType */ public interface TerremarkECloudMediaType extends TerremarkVCloudMediaType { @@ -35,7 +35,7 @@ public interface TerremarkECloudMediaType extends TerremarkVCloudMediaType { * "application/vnd.tmrk.ecloud.publicIp+xml" */ public final static MediaType PUBLICIP_XML_TYPE = new MediaType("application", "vnd.tmrk.ecloud.publicIp+xml"); - + /** * "application/vnd.tmrk.ecloud.internetService+xml" */ @@ -66,15 +66,24 @@ public interface TerremarkECloudMediaType extends TerremarkVCloudMediaType { * "application/vnd.tmrk.ecloud.keysList+xml" */ public final static MediaType KEYSLIST_XML_TYPE = new MediaType("application", "vnd.tmrk.ecloud.keysList+xml"); - - + /** * "application/vnd.tmrk.ecloud.ipAddressList+xml" */ public final static String IPADDRESS_LIST_XML = "application/vnd.tmrk.ecloud.ipAddressList+xml"; - + /** * "application/vnd.tmrk.ecloud.ipAddressList+xml" */ public final static MediaType IPADDRESSES_LIST_XML_TYPE = new MediaType("application", "vnd.tmrk.ecloud.ipAddressList+xml"); + + /** + * "application/vnd.tmrk.ecloud.vApp+xml" + */ + public final static String VAPPEXTINFO_XML = "application/vnd.tmrk.ecloud.vApp+xml"; + + /** + * "application/vnd.tmrk.ecloud.vApp+xml" + */ + public final static MediaType VAPPEXTINFO_XML_TYPE = new MediaType("application", "vnd.tmrk.ecloud.vApp+xml"); } diff --git a/providers/trmk-ecloud/src/main/java/org/jclouds/vcloud/terremark/TerremarkECloudPropertiesBuilder.java b/providers/trmk-ecloud/src/main/java/org/jclouds/vcloud/terremark/TerremarkECloudPropertiesBuilder.java index f5c256d726..129f404f68 100644 --- a/providers/trmk-ecloud/src/main/java/org/jclouds/vcloud/terremark/TerremarkECloudPropertiesBuilder.java +++ b/providers/trmk-ecloud/src/main/java/org/jclouds/vcloud/terremark/TerremarkECloudPropertiesBuilder.java @@ -38,10 +38,10 @@ public class TerremarkECloudPropertiesBuilder extends TerremarkVCloudPropertiesB protected Properties defaultProperties() { Properties properties = super.defaultProperties(); properties.setProperty(PROPERTY_ISO3166_CODES, "US-FL,NL-NH"); - properties.setProperty(PROPERTY_API_VERSION, "0.8b-ext2.7"); + properties.setProperty(PROPERTY_API_VERSION, "0.8b-ext2.8"); properties.setProperty(PROPERTY_ENDPOINT, "https://services.enterprisecloud.terremark.com/api"); properties.setProperty(PROPERTY_TERREMARK_EXTENSION_NAME, "eCloudExtensions"); - properties.setProperty(PROPERTY_TERREMARK_EXTENSION_VERSION, "2.7"); + properties.setProperty(PROPERTY_TERREMARK_EXTENSION_VERSION, "2.8"); // default for ubuntu properties.setProperty(PROPERTY_VCLOUD_TIMEOUT_TASK_COMPLETED, 360l * 1000l + ""); // ubuntu image has a problem with sftp diff --git a/providers/trmk-ecloud/src/test/java/org/jclouds/vcloud/terremark/TerremarkECloudAsyncClientTest.java b/providers/trmk-ecloud/src/test/java/org/jclouds/vcloud/terremark/TerremarkECloudAsyncClientTest.java index 5fc7bb4e75..808eb5acf8 100644 --- a/providers/trmk-ecloud/src/test/java/org/jclouds/vcloud/terremark/TerremarkECloudAsyncClientTest.java +++ b/providers/trmk-ecloud/src/test/java/org/jclouds/vcloud/terremark/TerremarkECloudAsyncClientTest.java @@ -82,6 +82,7 @@ import org.jclouds.vcloud.terremark.xml.NodesHandler; import org.jclouds.vcloud.terremark.xml.PublicIpAddressesHandler; import org.jclouds.vcloud.terremark.xml.TerremarkOrgNetworkFromTerremarkVCloudExpressNetworkHandler; import org.jclouds.vcloud.terremark.xml.TerremarkVDCHandler; +import org.jclouds.vcloud.terremark.xml.VAppExtendedInfoHandler; import org.jclouds.vcloud.xml.VCloudExpressCatalogHandler; import org.jclouds.vcloud.xml.VCloudExpressVAppHandler; import org.testng.annotations.Test; @@ -308,7 +309,7 @@ public class TerremarkECloudAsyncClientTest extends RestClientTestnametrueeggs", + "nametrueeggs", "application/vnd.tmrk.vCloud.nodeService+xml", false); assertResponseParserClassEquals(method, request, ParseSax.class); assertSaxResponseParserClassEquals(method, NodeHandler.class); @@ -422,7 +423,7 @@ public class TerremarkECloudAsyncClientTest extends RestClientTestnametrue", + "nametrue", "application/vnd.tmrk.vCloud.nodeService+xml", false); assertResponseParserClassEquals(method, request, ParseSax.class); assertSaxResponseParserClassEquals(method, NodeHandler.class); @@ -544,6 +545,21 @@ public class TerremarkECloudAsyncClientTest extends RestClientTest - \ No newline at end of file + From 35d5131ba974ba00da6659c414b3ceb168920948 Mon Sep 17 00:00:00 2001 From: Seshu Pasam Date: Tue, 12 Jul 2011 13:35:28 -0400 Subject: [PATCH 126/264] Oops, missed some files in previous commit. New files for vApp extended info. --- .../terremark/domain/NetworkAdapter.java | 92 +++++++++++++ .../vcloud/terremark/domain/Subnet.java | 82 +++++++++++ .../terremark/domain/VAppExtendedInfo.java | 128 ++++++++++++++++++ .../xml/VAppExtendedInfoHandler.java | 125 +++++++++++++++++ 4 files changed, 427 insertions(+) create mode 100644 common/trmk/src/main/java/org/jclouds/vcloud/terremark/domain/NetworkAdapter.java create mode 100644 common/trmk/src/main/java/org/jclouds/vcloud/terremark/domain/Subnet.java create mode 100644 common/trmk/src/main/java/org/jclouds/vcloud/terremark/domain/VAppExtendedInfo.java create mode 100644 common/trmk/src/main/java/org/jclouds/vcloud/terremark/xml/VAppExtendedInfoHandler.java diff --git a/common/trmk/src/main/java/org/jclouds/vcloud/terremark/domain/NetworkAdapter.java b/common/trmk/src/main/java/org/jclouds/vcloud/terremark/domain/NetworkAdapter.java new file mode 100644 index 0000000000..ce609770e4 --- /dev/null +++ b/common/trmk/src/main/java/org/jclouds/vcloud/terremark/domain/NetworkAdapter.java @@ -0,0 +1,92 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.jclouds.vcloud.terremark.domain; + +/** + * @author Seshu Pasam + */ +public class NetworkAdapter implements Comparable { + private final String macAddress; + private final String name; + private final Subnet subnet; + + public NetworkAdapter(String macAddress, String name, Subnet subnet) { + this.macAddress = macAddress; + this.name = name; + this.subnet = subnet; + } + + public int compareTo(NetworkAdapter that) { + return (this == that) ? 0 : getMacAddress().compareTo(that.getMacAddress()); + } + + public String getMacAddress() { + return macAddress; + } + + public String getName() { + return name; + } + + public Subnet getSubnet() { + return subnet; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((macAddress== null) ? 0 : macAddress.hashCode()); + result = prime * result + ((name == null) ? 0 : name.hashCode()); + result = prime * result + ((subnet == null) ? 0 : subnet.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + NetworkAdapter other = (NetworkAdapter) obj; + if (macAddress == null) { + if (other.macAddress != null) + return false; + } else if (!macAddress.equals(other.macAddress)) + return false; + if (name == null) { + if (other.name != null) + return false; + } else if (!name.equals(other.name)) + return false; + if (subnet == null) { + if (other.subnet != null) + return false; + } else if (!subnet.equals(other.subnet)) + return false; + return true; + } + + @Override + public String toString() { + return "[MAC address=" + macAddress + ", name=" + name + ", subnet=" + subnet + "]"; + } +} diff --git a/common/trmk/src/main/java/org/jclouds/vcloud/terremark/domain/Subnet.java b/common/trmk/src/main/java/org/jclouds/vcloud/terremark/domain/Subnet.java new file mode 100644 index 0000000000..764a91a62b --- /dev/null +++ b/common/trmk/src/main/java/org/jclouds/vcloud/terremark/domain/Subnet.java @@ -0,0 +1,82 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.jclouds.vcloud.terremark.domain; + +import java.net.URI; + +/** + * @author Seshu Pasam + */ +public class Subnet implements Comparable { + private final URI href; + private final String name; + + public Subnet(URI href, String name) { + this.href = href; + this.name = name; + } + + public int compareTo(Subnet that) { + return (this == that) ? 0 : getHref().compareTo(that.getHref()); + } + + public URI getHref() { + return href; + } + + public String getName() { + return name; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((href == null) ? 0 : href.hashCode()); + result = prime * result + ((name == null) ? 0 : name.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + Subnet other = (Subnet) obj; + if (href == null) { + if (other.href != null) + return false; + } else if (!href.equals(other.href)) + return false; + if (name == null) { + if (other.name != null) + return false; + } else if (!name.equals(other.name)) + return false; + return true; + } + + @Override + public String toString() { + return "[href=" + href + ", name=" + name + "]"; + } +} diff --git a/common/trmk/src/main/java/org/jclouds/vcloud/terremark/domain/VAppExtendedInfo.java b/common/trmk/src/main/java/org/jclouds/vcloud/terremark/domain/VAppExtendedInfo.java new file mode 100644 index 0000000000..7fb8e7af69 --- /dev/null +++ b/common/trmk/src/main/java/org/jclouds/vcloud/terremark/domain/VAppExtendedInfo.java @@ -0,0 +1,128 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.jclouds.vcloud.terremark.domain; + +import java.net.URI; +import java.util.List; + +/** + * @author Seshu Pasam + */ +public class VAppExtendedInfo implements Comparable { + private final String id; + private final URI href; + private final String name; + private final List tags; + private final String longName; + private final List networkAdapters; + + public VAppExtendedInfo(String id, URI href, String name, List tags, String longName, + List networkAdapters) { + this.id = id; + this.href = href; + this.name = name; + this.tags = tags; + this.longName = longName; + this.networkAdapters = networkAdapters; + } + + public int compareTo(VAppExtendedInfo that) { + return (this == that) ? 0 : getHref().compareTo(that.getHref()); + } + + public String getId() { + return id; + } + + public URI getHref() { + return href; + } + + public String getName() { + return name; + } + + public List getTags() { + return tags; + } + + public String getLongName() { + return longName; + } + + public List getNetworkAdapters() { + return networkAdapters; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((href == null) ? 0 : href.hashCode()); + result = prime * result + ((id == null) ? 0 : id.hashCode()); + result = prime * result + ((name == null) ? 0 : name.hashCode()); + result = prime * result + ((longName == null) ? 0 : longName.hashCode()); + result = prime * result + ((tags == null) ? 0 : tags.hashCode()); + result = prime * result + ((networkAdapters == null) ? 0 : networkAdapters.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + VAppExtendedInfo other = (VAppExtendedInfo) obj; + if (href == null) { + if (other.href != null) + return false; + } else if (!href.equals(other.href)) + return false; + if (id == null) { + if (other.id != null) + return false; + } else if (!id.equals(other.id)) + return false; + if (name == null) { + if (other.name != null) + return false; + } else if (!name.equals(other.name)) + return false; + if (tags == null) { + if (other.tags != null) + return false; + } else if (!tags.equals(other.tags)) + return false; + if (networkAdapters == null) { + if (other.networkAdapters != null) + return false; + } else if (!networkAdapters.equals(other.networkAdapters)) + return false; + return true; + } + + @Override + public String toString() { + return "[href=" + href + ", id=" + id + ", name=" + name + ", long name=" + longName + + ", tags=" + tags.toString() + ", network adapters=" + networkAdapters.toString() + "]"; + } +} diff --git a/common/trmk/src/main/java/org/jclouds/vcloud/terremark/xml/VAppExtendedInfoHandler.java b/common/trmk/src/main/java/org/jclouds/vcloud/terremark/xml/VAppExtendedInfoHandler.java new file mode 100644 index 0000000000..5bf429f6fd --- /dev/null +++ b/common/trmk/src/main/java/org/jclouds/vcloud/terremark/xml/VAppExtendedInfoHandler.java @@ -0,0 +1,125 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.jclouds.vcloud.terremark.xml; + +import java.net.URI; +import java.util.Arrays; +import java.util.ArrayList; +import java.util.List; + +import javax.annotation.Resource; + +import org.jclouds.http.functions.ParseSax.HandlerWithResult; +import org.jclouds.logging.Logger; +import org.jclouds.vcloud.terremark.domain.VAppExtendedInfo; +import org.jclouds.vcloud.terremark.domain.NetworkAdapter; +import org.jclouds.vcloud.terremark.domain.Subnet; +import org.xml.sax.Attributes; +import org.xml.sax.SAXException; + +import com.google.common.collect.Lists; + +/** + * @author Seshu Pasam + */ +public class VAppExtendedInfoHandler extends HandlerWithResult { + + @Resource + protected Logger logger = Logger.NULL; + private StringBuilder currentText = new StringBuilder(); + + private String id; + private URI href; + private String name; + private String longName; + private List tags; + private List networkAdapters = Lists.newArrayList(); + private boolean inAdapters; + private String macAddress; + private String adapterName; + private boolean inSubnet; + private Subnet subnet; + private URI subnetLocation; + private String subnetName; + + protected String currentOrNull() { + String returnVal = currentText.toString().trim(); + return returnVal.equals("") ? null : returnVal; + } + + @Override + public VAppExtendedInfo getResult() { + return new VAppExtendedInfo(id, href, name, tags, longName, networkAdapters); + } + + @Override + public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException { + if (qName.equals("NetworkAdapters")) { + inAdapters = true; + } else if (qName.equals("Subnet")) { + inSubnet = true; + } + } + + public void endElement(String uri, String name, String qName) { + String current = currentOrNull(); + if (current != null) { + if (qName.equals("Id")) { + this.id = current; + } else if (qName.equals("Tags")) { + this.tags = Arrays.asList(current.split(",")); + } else if (qName.equals("LongName")) { + this.longName = current; + } else if (qName.equals("Href")) { + if (inSubnet) { + this.subnetLocation = URI.create(current); + } else { + this.href = URI.create(current); + } + } else if (qName.equals("Name")) { + if (inSubnet) { + this.subnetName = current; + } else if (inAdapters) { + this.adapterName = current; + } else { + this.name = current; + } + } else if (qName.equals("NetworkAdapters")) { + inAdapters = false; + } else if (qName.equals("NetworkAdapter")) { + networkAdapters.add(new NetworkAdapter(macAddress, adapterName, subnet)); + macAddress = null; + adapterName = null; + subnet = null; + } else if (qName.equals("MacAddress")) { + macAddress = current; + } else if (qName.equals("Subnet")) { + subnet = new Subnet(subnetLocation, subnetName); + subnetLocation = null; + subnetName = null; + inSubnet = false; + } + } + currentText = new StringBuilder(); + } + + public void characters(char ch[], int start, int length) { + currentText.append(ch, start, length); + } +} From 19339b807abbba48fcef26c211bfcffebd4d7bbf Mon Sep 17 00:00:00 2001 From: Ben Mabey Date: Tue, 12 Jul 2011 16:46:54 -0600 Subject: [PATCH 127/264] fixes clojure's blobstore clear-container wrapper fn --- blobstore/src/main/clojure/org/jclouds/blobstore2.clj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/blobstore/src/main/clojure/org/jclouds/blobstore2.clj b/blobstore/src/main/clojure/org/jclouds/blobstore2.clj index d1dfcbd47b..757561a275 100644 --- a/blobstore/src/main/clojure/org/jclouds/blobstore2.clj +++ b/blobstore/src/main/clojure/org/jclouds/blobstore2.clj @@ -223,7 +223,7 @@ Options can also be specified for extension modules (defn clear-container "Clear a container." - [^BlobStore container-name] + [^BlobStore blobstore container-name] (.clearContainer blobstore container-name)) (defn delete-container @@ -348,4 +348,4 @@ Options can also be specified for extension modules (.getETag blob)) (defn blob-md5 [blob] - (.getContentMD5 blob)) \ No newline at end of file + (.getContentMD5 blob)) From 46c7822b4ad4bba827e3019fe576109d20373a41 Mon Sep 17 00:00:00 2001 From: Adrian Cole Date: Tue, 12 Jul 2011 20:53:06 -0700 Subject: [PATCH 128/264] Issue 624:update terremark config to use ubuntu 10.04 templates --- ...markVCloudComputeServiceContextModule.java | 10 ------- ...kVCloudExpressTemplateBuilderLiveTest.java | 28 +++++++++---------- 2 files changed, 14 insertions(+), 24 deletions(-) diff --git a/common/trmk/src/main/java/org/jclouds/vcloud/terremark/compute/config/TerremarkVCloudComputeServiceContextModule.java b/common/trmk/src/main/java/org/jclouds/vcloud/terremark/compute/config/TerremarkVCloudComputeServiceContextModule.java index d88dd9801e..cdc4755768 100644 --- a/common/trmk/src/main/java/org/jclouds/vcloud/terremark/compute/config/TerremarkVCloudComputeServiceContextModule.java +++ b/common/trmk/src/main/java/org/jclouds/vcloud/terremark/compute/config/TerremarkVCloudComputeServiceContextModule.java @@ -18,8 +18,6 @@ */ package org.jclouds.vcloud.terremark.compute.config; -import static org.jclouds.compute.domain.OsFamily.UBUNTU; - import java.security.SecureRandom; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; @@ -31,7 +29,6 @@ import org.jclouds.compute.ComputeService; import org.jclouds.compute.config.BindComputeStrategiesByClass; import org.jclouds.compute.config.BindComputeSuppliersByClass; import org.jclouds.compute.domain.NodeMetadata; -import org.jclouds.compute.domain.TemplateBuilder; import org.jclouds.compute.options.TemplateOptions; import org.jclouds.compute.strategy.PopulateDefaultLoginCredentialsForImageStrategy; import org.jclouds.vcloud.compute.VCloudExpressComputeClient; @@ -48,7 +45,6 @@ import org.jclouds.vcloud.terremark.compute.strategy.ParseVAppTemplateDescriptio import com.google.common.base.Function; import com.google.common.base.Supplier; -import com.google.inject.Injector; import com.google.inject.Provides; import com.google.inject.TypeLiteral; @@ -72,12 +68,6 @@ public class TerremarkVCloudComputeServiceContextModule extends VCloudExpressCom } - // prefer jeos as the copy time is much shorter - @Override - protected TemplateBuilder provideTemplate(Injector injector, TemplateBuilder template) { - return template.osFamily(UBUNTU).osDescriptionMatches(".*JeOS.*").os64Bit(true); - } - @Override protected void configure() { super.configure(); diff --git a/providers/trmk-vcloudexpress/src/test/java/org/jclouds/vcloud/terremark/compute/TerremarkVCloudExpressTemplateBuilderLiveTest.java b/providers/trmk-vcloudexpress/src/test/java/org/jclouds/vcloud/terremark/compute/TerremarkVCloudExpressTemplateBuilderLiveTest.java index ad655f429b..5cc47405e7 100644 --- a/providers/trmk-vcloudexpress/src/test/java/org/jclouds/vcloud/terremark/compute/TerremarkVCloudExpressTemplateBuilderLiveTest.java +++ b/providers/trmk-vcloudexpress/src/test/java/org/jclouds/vcloud/terremark/compute/TerremarkVCloudExpressTemplateBuilderLiveTest.java @@ -31,6 +31,7 @@ import org.jclouds.compute.domain.Template; import org.testng.annotations.Test; import com.google.common.base.Predicate; +import com.google.common.base.Predicates; import com.google.common.collect.ImmutableSet; /** @@ -46,30 +47,29 @@ public class TerremarkVCloudExpressTemplateBuilderLiveTest extends BaseTemplateB @Override protected Predicate defineUnsupportedOperatingSystems() { - return new Predicate() { + return Predicates.not(new Predicate() { @Override public boolean apply(OsFamilyVersion64Bit input) { switch (input.family) { - case RHEL: - return !input.version.equals("") && !input.version.equals("5.0"); - case CENTOS: - return !input.version.equals("") && !input.version.matches("5.0"); - case UBUNTU: - return !input.version.equals("") && !(input.version.equals("9.04") || input.version.equals("9.10")); - case WINDOWS: - return !input.version.equals("") && !input.version.equals("2003") // - && !input.version.equals("2008"); - default: - return true; + case RHEL: + return input.version.equals("") || input.version.equals("5.0"); + case CENTOS: + return input.version.equals("") || input.version.equals("5.0"); + case UBUNTU: + return input.version.equals("") || input.version.matches("9.[10][04]") || input.version.equals("10.04"); + case WINDOWS: + return input.version.equals("") || input.version.equals("2003") || input.version.equals("2008"); + default: + return false; } } - }; + }); } @Test public void testDefaultTemplateBuilder() throws IOException { Template defaultTemplate = context.getComputeService().templateBuilder().build(); - assertEquals(defaultTemplate.getImage().getOperatingSystem().getVersion(), "9.10"); + assertEquals(defaultTemplate.getImage().getOperatingSystem().getVersion(), "10.04"); assertEquals(defaultTemplate.getImage().getOperatingSystem().is64Bit(), true); assertEquals(defaultTemplate.getImage().getOperatingSystem().getFamily(), OsFamily.UBUNTU); assertEquals(getCores(defaultTemplate.getHardware()), 1.0d); From 92bcb2b822f40360e721f2a27a6cfcc48e5fbcf5 Mon Sep 17 00:00:00 2001 From: Adrian Cole Date: Wed, 13 Jul 2011 14:30:32 -0700 Subject: [PATCH 129/264] Issue 622:Unable to clone machine of Terremark VCloud Express --- .../BindCloneVAppParamsToXmlPayload.java | 2 +- .../src/test/resources/copyVApp-default.xml | 2 +- apis/vcloud/src/test/resources/copyVApp.xml | 2 +- apis/vcloud/src/test/resources/moveVApp.xml | 2 +- .../vcloud/VCloudExpressAsyncClient.java | 4 +- ...eVCloudExpressVAppParamsToXmlPayload.java} | 6 +- ...oudExpressVAppParamsToXmlPayloadTest.java} | 6 +- ...ssBindCloneVAppParamsToXmlPayloadTest.java | 98 ------------------- ...remarkBindCloneVAppParamsToXmlPayload.java | 4 +- 9 files changed, 14 insertions(+), 112 deletions(-) rename apis/vcloudexpress/src/main/java/org/jclouds/vcloud/binders/{BindCloneVAppParamsToXmlPayload.java => BindCloneVCloudExpressVAppParamsToXmlPayload.java} (95%) rename apis/vcloudexpress/src/test/java/org/jclouds/vcloud/binders/{BindCloneVAppParamsToXmlPayloadTest.java => BindCloneVCloudExpressVAppParamsToXmlPayloadTest.java} (91%) delete mode 100644 apis/vcloudexpress/src/test/java/org/jclouds/vcloud/binders/VCloudExpressBindCloneVAppParamsToXmlPayloadTest.java diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/binders/BindCloneVAppParamsToXmlPayload.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/binders/BindCloneVAppParamsToXmlPayload.java index b5d83ca1d3..41cdeb8ffa 100644 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/binders/BindCloneVAppParamsToXmlPayload.java +++ b/apis/vcloud/src/main/java/org/jclouds/vcloud/binders/BindCloneVAppParamsToXmlPayload.java @@ -42,7 +42,7 @@ public class BindCloneVAppParamsToXmlPayload extends BindCloneParamsToXmlPayload @Inject public BindCloneVAppParamsToXmlPayload(BindToStringPayload stringBinder, @Named(PROPERTY_VCLOUD_XML_NAMESPACE) String ns, @Named(PROPERTY_VCLOUD_XML_SCHEMA) String schema) { - super(stringBinder, schema, schema); + super(stringBinder, ns, schema); } @Override diff --git a/apis/vcloud/src/test/resources/copyVApp-default.xml b/apis/vcloud/src/test/resources/copyVApp-default.xml index e1579ca3c2..0e8ba8df38 100644 --- a/apis/vcloud/src/test/resources/copyVApp-default.xml +++ b/apis/vcloud/src/test/resources/copyVApp-default.xml @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/apis/vcloud/src/test/resources/copyVApp.xml b/apis/vcloud/src/test/resources/copyVApp.xml index 11dfaaeeaf..b6cd73359a 100644 --- a/apis/vcloud/src/test/resources/copyVApp.xml +++ b/apis/vcloud/src/test/resources/copyVApp.xml @@ -1 +1 @@ -The description of the new vApp \ No newline at end of file +The description of the new vApp \ No newline at end of file diff --git a/apis/vcloud/src/test/resources/moveVApp.xml b/apis/vcloud/src/test/resources/moveVApp.xml index cba62d94aa..919d13655f 100644 --- a/apis/vcloud/src/test/resources/moveVApp.xml +++ b/apis/vcloud/src/test/resources/moveVApp.xml @@ -1 +1 @@ -The description of the new vApptrue \ No newline at end of file +The description of the new vApptrue \ No newline at end of file diff --git a/apis/vcloudexpress/src/main/java/org/jclouds/vcloud/VCloudExpressAsyncClient.java b/apis/vcloudexpress/src/main/java/org/jclouds/vcloud/VCloudExpressAsyncClient.java index 68048ec141..bbe3120007 100644 --- a/apis/vcloudexpress/src/main/java/org/jclouds/vcloud/VCloudExpressAsyncClient.java +++ b/apis/vcloudexpress/src/main/java/org/jclouds/vcloud/VCloudExpressAsyncClient.java @@ -44,7 +44,7 @@ import org.jclouds.rest.annotations.RequestFilters; import org.jclouds.rest.annotations.ResponseParser; import org.jclouds.rest.annotations.XMLResponseParser; import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404; -import org.jclouds.vcloud.binders.BindCloneVAppParamsToXmlPayload; +import org.jclouds.vcloud.binders.BindCloneVCloudExpressVAppParamsToXmlPayload; import org.jclouds.vcloud.binders.BindInstantiateVCloudExpressVAppTemplateParamsToXmlPayload; import org.jclouds.vcloud.domain.Catalog; import org.jclouds.vcloud.domain.Task; @@ -163,7 +163,7 @@ public interface VCloudExpressAsyncClient extends CommonVCloudAsyncClient { @Produces("application/vnd.vmware.vcloud.cloneVAppParams+xml") @Consumes(TASK_XML) @XMLResponseParser(TaskHandler.class) - @MapBinder(BindCloneVAppParamsToXmlPayload.class) + @MapBinder(BindCloneVCloudExpressVAppParamsToXmlPayload.class) ListenableFuture cloneVAppInVDC(@EndpointParam URI vdc, @PayloadParam("vApp") URI toClone, @PayloadParam("newName") @ParamValidators(DnsNameValidator.class) String newName, CloneVAppOptions... options); diff --git a/apis/vcloudexpress/src/main/java/org/jclouds/vcloud/binders/BindCloneVAppParamsToXmlPayload.java b/apis/vcloudexpress/src/main/java/org/jclouds/vcloud/binders/BindCloneVCloudExpressVAppParamsToXmlPayload.java similarity index 95% rename from apis/vcloudexpress/src/main/java/org/jclouds/vcloud/binders/BindCloneVAppParamsToXmlPayload.java rename to apis/vcloudexpress/src/main/java/org/jclouds/vcloud/binders/BindCloneVCloudExpressVAppParamsToXmlPayload.java index 22cfb4af43..2312dd9935 100644 --- a/apis/vcloudexpress/src/main/java/org/jclouds/vcloud/binders/BindCloneVAppParamsToXmlPayload.java +++ b/apis/vcloudexpress/src/main/java/org/jclouds/vcloud/binders/BindCloneVCloudExpressVAppParamsToXmlPayload.java @@ -49,14 +49,14 @@ import com.jamesmurty.utils.XMLBuilder; * */ @Singleton -public class BindCloneVAppParamsToXmlPayload implements MapBinder { +public class BindCloneVCloudExpressVAppParamsToXmlPayload implements MapBinder { protected final String ns; protected final String schema; private final BindToStringPayload stringBinder; @Inject - public BindCloneVAppParamsToXmlPayload(BindToStringPayload stringBinder, + public BindCloneVCloudExpressVAppParamsToXmlPayload(BindToStringPayload stringBinder, @Named(PROPERTY_VCLOUD_XML_NAMESPACE) String ns, @Named(PROPERTY_VCLOUD_XML_SCHEMA) String schema) { this.ns = ns; this.schema = schema; @@ -93,7 +93,7 @@ public class BindCloneVAppParamsToXmlPayload implements MapBinder { XMLBuilder rootBuilder = buildRoot(newName, options.isDeploy(), options.isPowerOn()); if (options.getDescription() != null) rootBuilder.e("Description").text(options.getDescription()); - rootBuilder.e("VApp").a("href", vApp).a("type", VCloudMediaType.VAPP_XML); + rootBuilder.e("VApp").a("xmlns", ns).a("href", vApp).a("type", VCloudMediaType.VAPP_XML); Properties outputProperties = new Properties(); outputProperties.put(javax.xml.transform.OutputKeys.OMIT_XML_DECLARATION, "yes"); return rootBuilder.asString(outputProperties); diff --git a/apis/vcloudexpress/src/test/java/org/jclouds/vcloud/binders/BindCloneVAppParamsToXmlPayloadTest.java b/apis/vcloudexpress/src/test/java/org/jclouds/vcloud/binders/BindCloneVCloudExpressVAppParamsToXmlPayloadTest.java similarity index 91% rename from apis/vcloudexpress/src/test/java/org/jclouds/vcloud/binders/BindCloneVAppParamsToXmlPayloadTest.java rename to apis/vcloudexpress/src/test/java/org/jclouds/vcloud/binders/BindCloneVCloudExpressVAppParamsToXmlPayloadTest.java index f90e4fc40a..6b94fb55e0 100644 --- a/apis/vcloudexpress/src/test/java/org/jclouds/vcloud/binders/BindCloneVAppParamsToXmlPayloadTest.java +++ b/apis/vcloudexpress/src/test/java/org/jclouds/vcloud/binders/BindCloneVCloudExpressVAppParamsToXmlPayloadTest.java @@ -47,7 +47,7 @@ import com.google.inject.name.Names; * @author Adrian Cole */ @Test(groups = "unit") -public class BindCloneVAppParamsToXmlPayloadTest { +public class BindCloneVCloudExpressVAppParamsToXmlPayloadTest { Injector injector = Guice.createInjector(new AbstractModule() { @Override @@ -70,7 +70,7 @@ public class BindCloneVAppParamsToXmlPayloadTest { request.setPayload(expected); replay(request); - BindCloneVAppParamsToXmlPayload binder = injector.getInstance(BindCloneVAppParamsToXmlPayload.class); + BindCloneVCloudExpressVAppParamsToXmlPayload binder = injector.getInstance(BindCloneVCloudExpressVAppParamsToXmlPayload.class); Map map = Maps.newHashMap(); map.put("newName", "new-linux-server"); @@ -88,7 +88,7 @@ public class BindCloneVAppParamsToXmlPayloadTest { request.setPayload(expected); replay(request); - BindCloneVAppParamsToXmlPayload binder = injector.getInstance(BindCloneVAppParamsToXmlPayload.class); + BindCloneVCloudExpressVAppParamsToXmlPayload binder = injector.getInstance(BindCloneVCloudExpressVAppParamsToXmlPayload.class); Map map = Maps.newHashMap(); map.put("newName", "my-vapp"); diff --git a/apis/vcloudexpress/src/test/java/org/jclouds/vcloud/binders/VCloudExpressBindCloneVAppParamsToXmlPayloadTest.java b/apis/vcloudexpress/src/test/java/org/jclouds/vcloud/binders/VCloudExpressBindCloneVAppParamsToXmlPayloadTest.java deleted file mode 100644 index 0d3c0eabc2..0000000000 --- a/apis/vcloudexpress/src/test/java/org/jclouds/vcloud/binders/VCloudExpressBindCloneVAppParamsToXmlPayloadTest.java +++ /dev/null @@ -1,98 +0,0 @@ -/** - * - * Copyright (C) 2011 Cloud Conscious, LLC. - * - * ==================================================================== - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ==================================================================== - */ -package org.jclouds.vcloud.binders; - -import static com.google.common.base.Preconditions.checkNotNull; -import static org.easymock.EasyMock.expect; -import static org.easymock.classextension.EasyMock.createMock; -import static org.easymock.classextension.EasyMock.replay; -import static org.easymock.classextension.EasyMock.verify; - -import java.io.IOException; -import java.net.URI; -import java.util.Map; -import java.util.Properties; - -import org.jclouds.rest.internal.GeneratedHttpRequest; -import org.jclouds.util.Strings2; -import org.jclouds.vcloud.VCloudExpressPropertiesBuilder; -import org.jclouds.vcloud.options.CloneVAppOptions; -import org.testng.annotations.Test; - -import com.google.common.collect.ImmutableList; -import com.google.common.collect.Maps; -import com.google.inject.AbstractModule; -import com.google.inject.Guice; -import com.google.inject.Injector; -import com.google.inject.name.Names; - -/** - * Tests behavior of {@code BindCloneVAppParamsToXmlPayload} - * - * @author Adrian Cole - */ -@Test(groups = "unit") -public class VCloudExpressBindCloneVAppParamsToXmlPayloadTest { - Injector injector = Guice.createInjector(new AbstractModule() { - - @Override - protected void configure() { - Properties props = new Properties(); - Names.bindProperties(binder(), checkNotNull(new VCloudExpressPropertiesBuilder(props).build(), "properties")); - } - }); - - public void testWithDescriptionDeployOn() throws IOException { - String expected = Strings2.toStringAndClose(getClass().getResourceAsStream("/cloneVApp.xml")); - - CloneVAppOptions options = new CloneVAppOptions().deploy().powerOn().withDescription( - "The description of the new vApp"); - GeneratedHttpRequest request = createMock(GeneratedHttpRequest.class); - expect(request.getEndpoint()).andReturn(URI.create("http://localhost/key")).anyTimes(); - expect(request.getArgs()).andReturn(ImmutableList.of( options)).atLeastOnce(); - request.setPayload(expected); - replay(request); - - BindCloneVAppParamsToXmlPayload binder = injector.getInstance(BindCloneVAppParamsToXmlPayload.class); - - Map map = Maps.newHashMap(); - map.put("newName", "new-linux-server"); - map.put("vApp", "https://vcloud.safesecureweb.com/api/v0.8/vapp/201"); - binder.bindToRequest(request, map); - verify(request); - } - - public void testDefault() throws IOException { - String expected = Strings2.toStringAndClose(getClass().getResourceAsStream("/cloneVApp-default.xml")); - - GeneratedHttpRequest request = createMock(GeneratedHttpRequest.class); - expect(request.getEndpoint()).andReturn(URI.create("http://localhost/key")).anyTimes(); - expect(request.getArgs()).andReturn(ImmutableList.of()).atLeastOnce(); - request.setPayload(expected); - replay(request); - - BindCloneVAppParamsToXmlPayload binder = injector.getInstance(BindCloneVAppParamsToXmlPayload.class); - - Map map = Maps.newHashMap(); - map.put("newName", "my-vapp"); - map.put("vApp", "https://vcloud.safesecureweb.com/api/v0.8/vapp/4181"); - binder.bindToRequest(request, map); - verify(request); - } -} diff --git a/common/trmk/src/main/java/org/jclouds/vcloud/terremark/binders/TerremarkBindCloneVAppParamsToXmlPayload.java b/common/trmk/src/main/java/org/jclouds/vcloud/terremark/binders/TerremarkBindCloneVAppParamsToXmlPayload.java index 34103872cf..b611e676f8 100644 --- a/common/trmk/src/main/java/org/jclouds/vcloud/terremark/binders/TerremarkBindCloneVAppParamsToXmlPayload.java +++ b/common/trmk/src/main/java/org/jclouds/vcloud/terremark/binders/TerremarkBindCloneVAppParamsToXmlPayload.java @@ -27,7 +27,7 @@ import javax.xml.parsers.FactoryConfigurationError; import javax.xml.parsers.ParserConfigurationException; import org.jclouds.rest.binders.BindToStringPayload; -import org.jclouds.vcloud.binders.BindCloneVAppParamsToXmlPayload; +import org.jclouds.vcloud.binders.BindCloneVCloudExpressVAppParamsToXmlPayload; import com.google.inject.Inject; import com.jamesmurty.utils.XMLBuilder; @@ -38,7 +38,7 @@ import com.jamesmurty.utils.XMLBuilder; * */ @Singleton -public class TerremarkBindCloneVAppParamsToXmlPayload extends BindCloneVAppParamsToXmlPayload { +public class TerremarkBindCloneVAppParamsToXmlPayload extends BindCloneVCloudExpressVAppParamsToXmlPayload { @Inject public TerremarkBindCloneVAppParamsToXmlPayload(BindToStringPayload stringBinder, From f81bb95ab0d9841675ff55f5ee208d168f85e264 Mon Sep 17 00:00:00 2001 From: Adrian Cole Date: Sun, 17 Jul 2011 18:44:44 +1000 Subject: [PATCH 130/264] Issue 542: updated terremark eCloud implementation to 2.8 version of Org and added Tag and DataCenter queries --- .../BaseVCloudExpressRestClientModule.java | 7 +- .../terremark/TerremarkVCloudAsyncClient.java | 11 + .../terremark/TerremarkVCloudClient.java | 12 + .../config/TerremarkRestClientModule.java | 14 +- .../vcloud/terremark/domain/DataCenter.java | 131 ++++++++++ .../terremark/domain/InternetService.java | 5 +- .../vcloud/terremark/domain/TerremarkOrg.java | 28 +- .../domain/internal/TerremarkOrgImpl.java | 27 +- .../domain/internal/TerremarkVDCImpl.java | 3 - .../terremark/endpoints/DataCenters.java | 39 +++ .../endpoints/{KeysList.java => Keys.java} | 2 +- .../vcloud/terremark/endpoints/Tags.java | 39 +++ .../terremark/endpoints/VAppCatalog.java | 39 +++ .../terremark/functions/OrgURIToEndpoint.java | 65 +++++ .../functions/OrgURIToKeysListEndpoint.java | 28 +- .../terremark/xml/DataCenterHandler.java | 67 +++++ .../terremark/xml/DataCentersHandler.java | 77 ++++++ .../terremark/xml/InternetServiceHandler.java | 76 +++--- .../xml/InternetServicesHandler.java | 48 ++-- .../terremark/xml/TerremarkOrgHandler.java | 36 ++- .../xml/VAppExtendedInfoHandler.java | 3 +- .../BaseTerremarkClientLiveTest.java | 115 +++++++++ .../terremark/TerremarkClientLiveTest.java | 13 +- .../terremark/xml/DataCenterHandlerTest.java | 47 ++++ .../terremark/xml/DataCentersHandlerTest.java | 52 ++++ .../xml/InternetServicesHandlerTest.java | 4 +- .../xml/TerremarkOrgHandlerTest.java | 8 +- common/trmk/src/test/resources/datacenter.xml | 9 + .../trmk/src/test/resources/datacenters.xml | 23 ++ .../test/clojure/org/jclouds/compute_test.clj | 1 - providers/trmk-ecloud/pom.xml | 2 +- .../ecloud/domain/TerremarkECloudOrg.java | 27 ++ .../internal/TerremarkECloudOrgImpl.java | 67 +++++ .../DataCenterOperationsAsyncClient.java | 55 ++++ .../features/DataCenterOperationsClient.java | 40 +++ .../features/TagOperationsAsyncClient.java | 53 ++++ .../ecloud/features/TagOperationsClient.java | 33 +++ .../OrgURIToDataCentersListEndpoint.java | 51 ++++ .../functions/OrgURIToTagsListEndpoint.java | 51 ++++ .../xml/TagNameToUsageCountHandler.java | 61 +++++ .../ecloud/xml/TerremarkECloudOrgHandler.java | 71 +++++ .../terremark/TerremarkECloudAsyncClient.java | 43 +++- .../terremark/TerremarkECloudClient.java | 37 ++- .../terremark/TerremarkECloudMediaType.java | 35 ++- ...markECloudParseOsFromVAppTemplateName.java | 4 +- .../TerremarkECloudRestClientModule.java | 12 +- .../BaseTerremarkECloudAsyncClientTest.java | 243 ++++++++++++++++++ .../BaseTerremarkECloudClientLiveTest.java | 31 +++ .../DataCenterOperationsAsyncClientTest.java | 70 +++++ .../DataCenterOperationsClientLiveTest.java | 45 ++++ .../TagOperationsAsyncClientTest.java | 68 +++++ .../features/TagOperationsClientLiveTest.java | 45 ++++ .../xml/TagNameToUsageCountHandlerTest.java | 73 ++++++ .../xml/TerremarkECloudOrgHandlerTest.java | 131 ++++++++++ .../TerremarkECloudAsyncClientTest.java | 219 +--------------- ...ECloudParseOsFromVAppTemplateNameTest.java | 66 ++--- .../src/test/resources/deviceTags.xml | 27 ++ .../src/test/resources/org-ecloud.xml | 12 + ...TerremarkVCloudExpressAsyncClientTest.java | 9 +- 59 files changed, 2333 insertions(+), 377 deletions(-) create mode 100644 common/trmk/src/main/java/org/jclouds/vcloud/terremark/domain/DataCenter.java create mode 100644 common/trmk/src/main/java/org/jclouds/vcloud/terremark/endpoints/DataCenters.java rename common/trmk/src/main/java/org/jclouds/vcloud/terremark/endpoints/{KeysList.java => Keys.java} (97%) create mode 100644 common/trmk/src/main/java/org/jclouds/vcloud/terremark/endpoints/Tags.java create mode 100644 common/trmk/src/main/java/org/jclouds/vcloud/terremark/endpoints/VAppCatalog.java create mode 100644 common/trmk/src/main/java/org/jclouds/vcloud/terremark/functions/OrgURIToEndpoint.java create mode 100644 common/trmk/src/main/java/org/jclouds/vcloud/terremark/xml/DataCenterHandler.java create mode 100644 common/trmk/src/main/java/org/jclouds/vcloud/terremark/xml/DataCentersHandler.java create mode 100644 common/trmk/src/test/java/org/jclouds/vcloud/terremark/BaseTerremarkClientLiveTest.java create mode 100644 common/trmk/src/test/java/org/jclouds/vcloud/terremark/xml/DataCenterHandlerTest.java create mode 100644 common/trmk/src/test/java/org/jclouds/vcloud/terremark/xml/DataCentersHandlerTest.java create mode 100644 common/trmk/src/test/resources/datacenter.xml create mode 100644 common/trmk/src/test/resources/datacenters.xml create mode 100644 providers/trmk-ecloud/src/main/java/org/jclouds/terremark/ecloud/domain/TerremarkECloudOrg.java create mode 100644 providers/trmk-ecloud/src/main/java/org/jclouds/terremark/ecloud/domain/internal/TerremarkECloudOrgImpl.java create mode 100644 providers/trmk-ecloud/src/main/java/org/jclouds/terremark/ecloud/features/DataCenterOperationsAsyncClient.java create mode 100644 providers/trmk-ecloud/src/main/java/org/jclouds/terremark/ecloud/features/DataCenterOperationsClient.java create mode 100644 providers/trmk-ecloud/src/main/java/org/jclouds/terremark/ecloud/features/TagOperationsAsyncClient.java create mode 100644 providers/trmk-ecloud/src/main/java/org/jclouds/terremark/ecloud/features/TagOperationsClient.java create mode 100644 providers/trmk-ecloud/src/main/java/org/jclouds/terremark/ecloud/functions/OrgURIToDataCentersListEndpoint.java create mode 100644 providers/trmk-ecloud/src/main/java/org/jclouds/terremark/ecloud/functions/OrgURIToTagsListEndpoint.java create mode 100644 providers/trmk-ecloud/src/main/java/org/jclouds/terremark/ecloud/xml/TagNameToUsageCountHandler.java create mode 100644 providers/trmk-ecloud/src/main/java/org/jclouds/terremark/ecloud/xml/TerremarkECloudOrgHandler.java create mode 100644 providers/trmk-ecloud/src/test/java/org/jclouds/terremark/ecloud/BaseTerremarkECloudAsyncClientTest.java create mode 100644 providers/trmk-ecloud/src/test/java/org/jclouds/terremark/ecloud/BaseTerremarkECloudClientLiveTest.java create mode 100644 providers/trmk-ecloud/src/test/java/org/jclouds/terremark/ecloud/features/DataCenterOperationsAsyncClientTest.java create mode 100644 providers/trmk-ecloud/src/test/java/org/jclouds/terremark/ecloud/features/DataCenterOperationsClientLiveTest.java create mode 100644 providers/trmk-ecloud/src/test/java/org/jclouds/terremark/ecloud/features/TagOperationsAsyncClientTest.java create mode 100644 providers/trmk-ecloud/src/test/java/org/jclouds/terremark/ecloud/features/TagOperationsClientLiveTest.java create mode 100644 providers/trmk-ecloud/src/test/java/org/jclouds/terremark/ecloud/xml/TagNameToUsageCountHandlerTest.java create mode 100644 providers/trmk-ecloud/src/test/java/org/jclouds/terremark/ecloud/xml/TerremarkECloudOrgHandlerTest.java create mode 100644 providers/trmk-ecloud/src/test/resources/deviceTags.xml create mode 100644 providers/trmk-ecloud/src/test/resources/org-ecloud.xml diff --git a/apis/vcloudexpress/src/main/java/org/jclouds/vcloud/config/BaseVCloudExpressRestClientModule.java b/apis/vcloudexpress/src/main/java/org/jclouds/vcloud/config/BaseVCloudExpressRestClientModule.java index 986d681d07..e356439a09 100644 --- a/apis/vcloudexpress/src/main/java/org/jclouds/vcloud/config/BaseVCloudExpressRestClientModule.java +++ b/apis/vcloudexpress/src/main/java/org/jclouds/vcloud/config/BaseVCloudExpressRestClientModule.java @@ -21,6 +21,7 @@ package org.jclouds.vcloud.config; import static com.google.common.base.Throwables.propagate; import static org.jclouds.Constants.PROPERTY_SESSION_INTERVAL; +import java.util.Map; import java.util.concurrent.TimeUnit; import javax.inject.Named; @@ -43,7 +44,6 @@ import com.google.common.base.Supplier; import com.google.inject.Provides; import com.google.inject.TypeLiteral; - /** * Configures the VCloud authentication service connection, including logging * and http transport. @@ -59,6 +59,11 @@ public abstract class BaseVCloudExpressRestClientModule syncClientType, Class asyncClientType, + Map, Class> delegateMap) { + super(syncClientType, asyncClientType, delegateMap); + } + @Override protected void configure() { bind(new TypeLiteral, Iterable>>() { diff --git a/common/trmk/src/main/java/org/jclouds/vcloud/terremark/TerremarkVCloudAsyncClient.java b/common/trmk/src/main/java/org/jclouds/vcloud/terremark/TerremarkVCloudAsyncClient.java index a199e49700..56fbf30848 100644 --- a/common/trmk/src/main/java/org/jclouds/vcloud/terremark/TerremarkVCloudAsyncClient.java +++ b/common/trmk/src/main/java/org/jclouds/vcloud/terremark/TerremarkVCloudAsyncClient.java @@ -57,9 +57,11 @@ import org.jclouds.rest.functions.ReturnVoidOnNotFoundOr404; import org.jclouds.vcloud.VCloudExpressAsyncClient; import org.jclouds.vcloud.VCloudExpressClient; import org.jclouds.vcloud.domain.Catalog; +import org.jclouds.vcloud.domain.ReferenceType; import org.jclouds.vcloud.domain.Task; import org.jclouds.vcloud.domain.VCloudExpressVApp; import org.jclouds.vcloud.domain.VDC; +import org.jclouds.vcloud.endpoints.Org; import org.jclouds.vcloud.filters.SetVCloudTokenCookie; import org.jclouds.vcloud.functions.OrgNameAndVDCNameToEndpoint; import org.jclouds.vcloud.functions.OrgNameCatalogNameItemNameToEndpoint; @@ -96,6 +98,7 @@ import org.jclouds.vcloud.xml.VCloudExpressCatalogHandler; import org.jclouds.vcloud.xml.VCloudExpressVAppHandler; import com.google.common.util.concurrent.ListenableFuture; +import com.google.inject.Provides; /** * Provides access to VCloud resources via their REST API. @@ -106,6 +109,14 @@ import com.google.common.util.concurrent.ListenableFuture; */ @RequestFilters(SetVCloudTokenCookie.class) public interface TerremarkVCloudAsyncClient extends VCloudExpressAsyncClient { + /** + * + * @return a listing of all orgs that the current user has access to. + */ + @Provides + @Org + Iterable listOrgs(); + /** * @see VCloudExpressClient#getCatalogItemInOrg */ diff --git a/common/trmk/src/main/java/org/jclouds/vcloud/terremark/TerremarkVCloudClient.java b/common/trmk/src/main/java/org/jclouds/vcloud/terremark/TerremarkVCloudClient.java index eed2fa45d2..68d377fc4c 100644 --- a/common/trmk/src/main/java/org/jclouds/vcloud/terremark/TerremarkVCloudClient.java +++ b/common/trmk/src/main/java/org/jclouds/vcloud/terremark/TerremarkVCloudClient.java @@ -26,8 +26,10 @@ import javax.annotation.Nullable; import org.jclouds.concurrent.Timeout; import org.jclouds.vcloud.VCloudExpressClient; +import org.jclouds.vcloud.domain.ReferenceType; import org.jclouds.vcloud.domain.Task; import org.jclouds.vcloud.domain.VCloudExpressVApp; +import org.jclouds.vcloud.endpoints.Org; import org.jclouds.vcloud.terremark.domain.CustomizationParameters; import org.jclouds.vcloud.terremark.domain.InternetService; import org.jclouds.vcloud.terremark.domain.KeyPair; @@ -41,6 +43,8 @@ import org.jclouds.vcloud.terremark.domain.VAppConfiguration; import org.jclouds.vcloud.terremark.options.AddInternetServiceOptions; import org.jclouds.vcloud.terremark.options.AddNodeOptions; +import com.google.inject.Provides; + /** * Provides access to VCloud resources via their REST API. *

    @@ -50,6 +54,14 @@ import org.jclouds.vcloud.terremark.options.AddNodeOptions; */ @Timeout(duration = 300, timeUnit = TimeUnit.SECONDS) public interface TerremarkVCloudClient extends VCloudExpressClient { + /** + * + * @return a listing of all orgs that the current user has access to. + */ + @Provides + @Org + Iterable listOrgs(); + /** * {@inheritDoc} */ diff --git a/common/trmk/src/main/java/org/jclouds/vcloud/terremark/config/TerremarkRestClientModule.java b/common/trmk/src/main/java/org/jclouds/vcloud/terremark/config/TerremarkRestClientModule.java index 7e91fea748..6cfb44c4f7 100644 --- a/common/trmk/src/main/java/org/jclouds/vcloud/terremark/config/TerremarkRestClientModule.java +++ b/common/trmk/src/main/java/org/jclouds/vcloud/terremark/config/TerremarkRestClientModule.java @@ -17,12 +17,11 @@ * ==================================================================== */ package org.jclouds.vcloud.terremark.config; - import static org.jclouds.Constants.PROPERTY_SESSION_INTERVAL; import java.io.IOException; import java.util.Map; - + import javax.inject.Inject; import javax.inject.Named; import javax.inject.Singleton; @@ -38,7 +37,7 @@ import org.jclouds.vcloud.domain.ReferenceType; import org.jclouds.vcloud.domain.VCloudSession; import org.jclouds.vcloud.terremark.TerremarkVCloudAsyncClient; import org.jclouds.vcloud.terremark.TerremarkVCloudClient; -import org.jclouds.vcloud.terremark.endpoints.KeysList; +import org.jclouds.vcloud.terremark.endpoints.Keys; import org.jclouds.vcloud.terremark.handlers.ParseTerremarkVCloudErrorFromHttpResponse; import com.google.common.base.Function; @@ -53,6 +52,11 @@ public abstract class TerremarkRestClientModule syncClientType, Class asyncClientType, + Map, Class> delegateMap) { + super(syncClientType, asyncClientType, delegateMap); + } + @Singleton @Provides @Named("CreateInternetService") @@ -96,7 +100,7 @@ public abstract class TerremarkRestClientModule> provideOrgToKeysListCache( @Named(PROPERTY_SESSION_INTERVAL) long seconds, final OrgNameToKeysListSupplier supplier) { return new MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier>(authException, diff --git a/common/trmk/src/main/java/org/jclouds/vcloud/terremark/domain/DataCenter.java b/common/trmk/src/main/java/org/jclouds/vcloud/terremark/domain/DataCenter.java new file mode 100644 index 0000000000..8e872e7c7b --- /dev/null +++ b/common/trmk/src/main/java/org/jclouds/vcloud/terremark/domain/DataCenter.java @@ -0,0 +1,131 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.jclouds.vcloud.terremark.domain; + + +/** + * + * @author Adrian Cole + */ +public class DataCenter { + public static Builder builder() { + return new Builder(); + } + + public static class Builder { + private String id; + private String name; + private String code; + + public Builder id(String id) { + this.id = id; + return this; + } + + public Builder name(String name) { + this.name = name; + return this; + } + + public Builder code(String code) { + this.code = code; + return this; + } + + public DataCenter build() { + return new DataCenter(id, name, code); + } + } + + private final String id; + private final String name; + private final String code; + + public DataCenter(String id, String name, String code) { + this.id = id; + this.name = name; + this.code = code; + } + + /** + * + * @return id of the data center + */ + public String getId() { + return id; + } + + /** + * + * @return name of the data center + */ + public String getName() { + return name; + } + + /** + * + * @return airport code of the data center + */ + public String getCode() { + return code; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((code == null) ? 0 : code.hashCode()); + result = prime * result + ((id == null) ? 0 : id.hashCode()); + result = prime * result + ((name == null) ? 0 : name.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + DataCenter other = (DataCenter) obj; + if (code == null) { + if (other.code != null) + return false; + } else if (!code.equals(other.code)) + return false; + if (id == null) { + if (other.id != null) + return false; + } else if (!id.equals(other.id)) + return false; + if (name == null) { + if (other.name != null) + return false; + } else if (!name.equals(other.name)) + return false; + return true; + } + + @Override + public String toString() { + return "[id=" + id + ", name=" + name + ", code=" + code + "]"; + } +} diff --git a/common/trmk/src/main/java/org/jclouds/vcloud/terremark/domain/InternetService.java b/common/trmk/src/main/java/org/jclouds/vcloud/terremark/domain/InternetService.java index 534f3aa342..a5e662166c 100644 --- a/common/trmk/src/main/java/org/jclouds/vcloud/terremark/domain/InternetService.java +++ b/common/trmk/src/main/java/org/jclouds/vcloud/terremark/domain/InternetService.java @@ -83,9 +83,8 @@ public class InternetService implements Comparable { @Override public String toString() { - return "InternetService [description=" + description + ", enabled=" + enabled + ", id=" + id + ", name=" - + name + ", port=" + port + ", protocol=" + protocol + ", publicIpAddress=" + publicIpAddress - + ", timeout=" + timeout + "]"; + return "[description=" + description + ", enabled=" + enabled + ", id=" + id + ", name=" + name + ", port=" + + port + ", protocol=" + protocol + ", publicIpAddress=" + publicIpAddress + ", timeout=" + timeout + "]"; } @Override diff --git a/common/trmk/src/main/java/org/jclouds/vcloud/terremark/domain/TerremarkOrg.java b/common/trmk/src/main/java/org/jclouds/vcloud/terremark/domain/TerremarkOrg.java index c475181d63..f077208c0b 100644 --- a/common/trmk/src/main/java/org/jclouds/vcloud/terremark/domain/TerremarkOrg.java +++ b/common/trmk/src/main/java/org/jclouds/vcloud/terremark/domain/TerremarkOrg.java @@ -18,10 +18,12 @@ */ package org.jclouds.vcloud.terremark.domain; -import org.jclouds.vcloud.domain.ReferenceType; +import java.util.Map; + import org.jclouds.vcloud.domain.Org; +import org.jclouds.vcloud.domain.ReferenceType; import org.jclouds.vcloud.terremark.domain.internal.TerremarkOrgImpl; -import org.jclouds.vcloud.terremark.endpoints.KeysList; +import org.jclouds.vcloud.terremark.endpoints.Keys; import com.google.inject.ImplementedBy; @@ -31,8 +33,26 @@ import com.google.inject.ImplementedBy; @org.jclouds.vcloud.endpoints.Org @ImplementedBy(TerremarkOrgImpl.class) public interface TerremarkOrg extends Org { - - @KeysList + /** + * + * @see #getKeys + */ + @Deprecated ReferenceType getKeysList(); + @Keys + ReferenceType getKeys(); + + /** + * there are multiple tasks lists in a terremark org + * + * @see #getTasksLists + */ + @Deprecated + ReferenceType getTasksList(); + + /** + */ + Map getTasksLists(); + } \ No newline at end of file diff --git a/common/trmk/src/main/java/org/jclouds/vcloud/terremark/domain/internal/TerremarkOrgImpl.java b/common/trmk/src/main/java/org/jclouds/vcloud/terremark/domain/internal/TerremarkOrgImpl.java index 9f9cd2f2cf..1b1f97d6b1 100644 --- a/common/trmk/src/main/java/org/jclouds/vcloud/terremark/domain/internal/TerremarkOrgImpl.java +++ b/common/trmk/src/main/java/org/jclouds/vcloud/terremark/domain/internal/TerremarkOrgImpl.java @@ -18,17 +18,19 @@ */ package org.jclouds.vcloud.terremark.domain.internal; +import static com.google.common.base.Preconditions.checkNotNull; + import java.net.URI; import java.util.Map; -import javax.annotation.Nullable; - import org.jclouds.vcloud.domain.ReferenceType; import org.jclouds.vcloud.domain.Task; import org.jclouds.vcloud.domain.internal.OrgImpl; import org.jclouds.vcloud.terremark.domain.TerremarkOrg; import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.Iterables; /** * Locations of resources in a Terremark vCloud @@ -39,12 +41,15 @@ import com.google.common.collect.ImmutableList; public class TerremarkOrgImpl extends OrgImpl implements TerremarkOrg { private final ReferenceType keysList; + private final ImmutableMap tasksLists; public TerremarkOrgImpl(String name, String type, URI id, String description, Map catalogs, - Map vdcs, Map networks, @Nullable ReferenceType tasksList, - ReferenceType keysList) { - super(name, type, id, name, description, catalogs, vdcs, networks, tasksList, ImmutableList. of()); - this.keysList = keysList; + Map vdcs, Map networks, Map tasksLists, + ReferenceType keysList) { + super(name, type, id, name, description, catalogs, vdcs, networks, Iterables.get(tasksLists.values(), 0), + ImmutableList. of()); + this.tasksLists = ImmutableMap.copyOf(checkNotNull(tasksLists, "tasksLists")); + this.keysList = checkNotNull(keysList, "keysList"); } @Override @@ -52,4 +57,14 @@ public class TerremarkOrgImpl extends OrgImpl implements TerremarkOrg { return keysList; } + @Override + public Map getTasksLists() { + return tasksLists; + } + + @Override + public ReferenceType getKeys() { + return keysList; + } + } \ No newline at end of file diff --git a/common/trmk/src/main/java/org/jclouds/vcloud/terremark/domain/internal/TerremarkVDCImpl.java b/common/trmk/src/main/java/org/jclouds/vcloud/terremark/domain/internal/TerremarkVDCImpl.java index 6a9402f1f7..78bf17c6ce 100644 --- a/common/trmk/src/main/java/org/jclouds/vcloud/terremark/domain/internal/TerremarkVDCImpl.java +++ b/common/trmk/src/main/java/org/jclouds/vcloud/terremark/domain/internal/TerremarkVDCImpl.java @@ -45,9 +45,6 @@ public class TerremarkVDCImpl extends VDCImpl implements TerremarkVDC { private final ReferenceType publicIps; private final ReferenceType internetServices; - /** The serialVersionUID */ - private static final long serialVersionUID = 8464716396538298809L; - public TerremarkVDCImpl(String name, String type, URI id, VDCStatus status, ReferenceType org, @Nullable String description, Iterable tasks, AllocationModel allocationModel, @Nullable Capacity storageCapacity, @Nullable Capacity cpuCapacity, @Nullable Capacity memoryCapacity, diff --git a/common/trmk/src/main/java/org/jclouds/vcloud/terremark/endpoints/DataCenters.java b/common/trmk/src/main/java/org/jclouds/vcloud/terremark/endpoints/DataCenters.java new file mode 100644 index 0000000000..305cf0149d --- /dev/null +++ b/common/trmk/src/main/java/org/jclouds/vcloud/terremark/endpoints/DataCenters.java @@ -0,0 +1,39 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.jclouds.vcloud.terremark.endpoints; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +import javax.inject.Qualifier; + +/** + * Related to Terremark Data Centers List. + * + * @author Adrian Cole + * + */ +@Retention(value = RetentionPolicy.RUNTIME) +@Target(value = { ElementType.TYPE, ElementType.FIELD, ElementType.PARAMETER, ElementType.METHOD }) +@Qualifier +public @interface DataCenters { + +} \ No newline at end of file diff --git a/common/trmk/src/main/java/org/jclouds/vcloud/terremark/endpoints/KeysList.java b/common/trmk/src/main/java/org/jclouds/vcloud/terremark/endpoints/Keys.java similarity index 97% rename from common/trmk/src/main/java/org/jclouds/vcloud/terremark/endpoints/KeysList.java rename to common/trmk/src/main/java/org/jclouds/vcloud/terremark/endpoints/Keys.java index 4d28e01e0c..811a4969f5 100644 --- a/common/trmk/src/main/java/org/jclouds/vcloud/terremark/endpoints/KeysList.java +++ b/common/trmk/src/main/java/org/jclouds/vcloud/terremark/endpoints/Keys.java @@ -34,6 +34,6 @@ import javax.inject.Qualifier; @Retention(value = RetentionPolicy.RUNTIME) @Target(value = { ElementType.TYPE, ElementType.FIELD, ElementType.PARAMETER, ElementType.METHOD }) @Qualifier -public @interface KeysList { +public @interface Keys { } \ No newline at end of file diff --git a/common/trmk/src/main/java/org/jclouds/vcloud/terremark/endpoints/Tags.java b/common/trmk/src/main/java/org/jclouds/vcloud/terremark/endpoints/Tags.java new file mode 100644 index 0000000000..e3d5a2b123 --- /dev/null +++ b/common/trmk/src/main/java/org/jclouds/vcloud/terremark/endpoints/Tags.java @@ -0,0 +1,39 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.jclouds.vcloud.terremark.endpoints; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +import javax.inject.Qualifier; + +/** + * Related to Terremark Device Tags. + * + * @author Adrian Cole + * + */ +@Retention(value = RetentionPolicy.RUNTIME) +@Target(value = { ElementType.TYPE, ElementType.FIELD, ElementType.PARAMETER, ElementType.METHOD }) +@Qualifier +public @interface Tags { + +} \ No newline at end of file diff --git a/common/trmk/src/main/java/org/jclouds/vcloud/terremark/endpoints/VAppCatalog.java b/common/trmk/src/main/java/org/jclouds/vcloud/terremark/endpoints/VAppCatalog.java new file mode 100644 index 0000000000..5dc78f57ab --- /dev/null +++ b/common/trmk/src/main/java/org/jclouds/vcloud/terremark/endpoints/VAppCatalog.java @@ -0,0 +1,39 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.jclouds.vcloud.terremark.endpoints; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +import javax.inject.Qualifier; + +/** + * Related to Terremark vApp Catalog + * + * @author Adrian Cole + * + */ +@Retention(value = RetentionPolicy.RUNTIME) +@Target(value = { ElementType.TYPE, ElementType.FIELD, ElementType.PARAMETER, ElementType.METHOD }) +@Qualifier +public @interface VAppCatalog { + +} \ No newline at end of file diff --git a/common/trmk/src/main/java/org/jclouds/vcloud/terremark/functions/OrgURIToEndpoint.java b/common/trmk/src/main/java/org/jclouds/vcloud/terremark/functions/OrgURIToEndpoint.java new file mode 100644 index 0000000000..208b02560e --- /dev/null +++ b/common/trmk/src/main/java/org/jclouds/vcloud/terremark/functions/OrgURIToEndpoint.java @@ -0,0 +1,65 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.jclouds.vcloud.terremark.functions; + +import java.net.URI; +import java.util.Map; + +import org.jclouds.rest.ResourceNotFoundException; +import org.jclouds.vcloud.domain.Org; +import org.jclouds.vcloud.terremark.domain.TerremarkOrg; + +import com.google.common.base.Function; +import com.google.common.base.Supplier; +import com.google.common.collect.Maps; + +/** + * + * @author Adrian Cole + */ +public abstract class OrgURIToEndpoint implements Function { + + protected final Supplier> orgMap; + protected final URI defaultOrg; + + public OrgURIToEndpoint(Supplier> orgMap, @org.jclouds.vcloud.endpoints.Org URI defaultUri) { + this.orgMap = orgMap; + this.defaultOrg = defaultUri; + } + + public URI apply(Object from) { + Map uriToOrg = Maps.uniqueIndex(orgMap.get().values(), new Function() { + + @Override + public URI apply(Org from) { + return from.getHref(); + } + + }); + try { + TerremarkOrg org = TerremarkOrg.class.cast(uriToOrg.get(from == null ? defaultOrg : from)); + return getUriFromOrg(org); + } catch (NullPointerException e) { + throw new ResourceNotFoundException("org " + from + " not found in: " + uriToOrg, e); + } + } + + protected abstract URI getUriFromOrg(TerremarkOrg org); + +} \ No newline at end of file diff --git a/common/trmk/src/main/java/org/jclouds/vcloud/terremark/functions/OrgURIToKeysListEndpoint.java b/common/trmk/src/main/java/org/jclouds/vcloud/terremark/functions/OrgURIToKeysListEndpoint.java index 063bc2d2ad..4f670f6759 100644 --- a/common/trmk/src/main/java/org/jclouds/vcloud/terremark/functions/OrgURIToKeysListEndpoint.java +++ b/common/trmk/src/main/java/org/jclouds/vcloud/terremark/functions/OrgURIToKeysListEndpoint.java @@ -24,44 +24,26 @@ import java.util.Map; import javax.inject.Inject; import javax.inject.Singleton; -import org.jclouds.rest.ResourceNotFoundException; import org.jclouds.vcloud.domain.Org; import org.jclouds.vcloud.terremark.domain.TerremarkOrg; import com.google.common.base.Function; import com.google.common.base.Supplier; -import com.google.common.collect.Maps; /** * * @author Adrian Cole */ @Singleton -public class OrgURIToKeysListEndpoint implements Function { - private final Supplier> orgMap; - private final URI defaultOrg; - +public class OrgURIToKeysListEndpoint extends OrgURIToEndpoint implements Function { @Inject public OrgURIToKeysListEndpoint(Supplier> orgMap, - @org.jclouds.vcloud.endpoints.Org URI defaultUri) { - this.orgMap = orgMap; - this.defaultOrg = defaultUri; + @org.jclouds.vcloud.endpoints.Org URI defaultUri) { + super(orgMap, defaultUri); } - public URI apply(Object from) { - Map uriToOrg = Maps.uniqueIndex(orgMap.get().values(), new Function() { - - @Override - public URI apply(Org from) { - return from.getHref(); - } - - }); - try { - return TerremarkOrg.class.cast(uriToOrg.get(from == null ? defaultOrg : from)).getKeysList().getHref(); - } catch (NullPointerException e) { - throw new ResourceNotFoundException("org " + from + " not found in: " + uriToOrg, e); - } + public URI getUriFromOrg(TerremarkOrg org) { + return org.getKeys().getHref(); } } \ No newline at end of file diff --git a/common/trmk/src/main/java/org/jclouds/vcloud/terremark/xml/DataCenterHandler.java b/common/trmk/src/main/java/org/jclouds/vcloud/terremark/xml/DataCenterHandler.java new file mode 100644 index 0000000000..ad4ef4866d --- /dev/null +++ b/common/trmk/src/main/java/org/jclouds/vcloud/terremark/xml/DataCenterHandler.java @@ -0,0 +1,67 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.jclouds.vcloud.terremark.xml; + +import static org.jclouds.util.SaxUtils.currentOrNull; +import static org.jclouds.util.SaxUtils.equalsOrSuffix; + +import org.jclouds.http.functions.ParseSax; +import org.jclouds.vcloud.terremark.domain.DataCenter; +import org.xml.sax.Attributes; + +/** + * @author Adrian Cole + */ +public class DataCenterHandler extends ParseSax.HandlerWithResult { + protected StringBuilder currentText = new StringBuilder(); + + protected DataCenter.Builder builder = DataCenter.builder(); + + public DataCenter getResult() { + try { + return builder.build(); + } finally { + builder = DataCenter.builder(); + } + } + + @Override + public void startElement(String uri, String localName, String qName, Attributes attrs) { + } + + @Override + public void endElement(String uri, String localName, String qName) { + String current = currentOrNull(currentText); + if (current != null) { + if (equalsOrSuffix(qName, "Id")) { + builder.id(current); + } else if (equalsOrSuffix(qName, "Code")) { + builder.code(current); + } else if (equalsOrSuffix(qName, "Name")) { + builder.name(current); + } + } + currentText = new StringBuilder(); + } + + public void characters(char ch[], int start, int length) { + currentText.append(ch, start, length); + } + +} diff --git a/common/trmk/src/main/java/org/jclouds/vcloud/terremark/xml/DataCentersHandler.java b/common/trmk/src/main/java/org/jclouds/vcloud/terremark/xml/DataCentersHandler.java new file mode 100644 index 0000000000..0bd331b96a --- /dev/null +++ b/common/trmk/src/main/java/org/jclouds/vcloud/terremark/xml/DataCentersHandler.java @@ -0,0 +1,77 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.jclouds.vcloud.terremark.xml; + +import static org.jclouds.util.SaxUtils.equalsOrSuffix; + +import java.util.Set; + +import javax.inject.Inject; + +import org.jclouds.http.functions.ParseSax; +import org.jclouds.vcloud.terremark.domain.DataCenter; +import org.xml.sax.Attributes; + +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.ImmutableSet.Builder; + +/** + * @author Adrian Cole + */ +public class DataCentersHandler extends ParseSax.HandlerWithResult> { + protected StringBuilder currentText = new StringBuilder(); + + protected Builder dataCenters = ImmutableSet. builder(); + + protected DataCenter.Builder builder = DataCenter.builder(); + + protected final DataCenterHandler handler; + + public Set getResult() { + try { + return dataCenters.build(); + } finally { + dataCenters = ImmutableSet. builder(); + } + } + + @Inject + public DataCentersHandler(DataCenterHandler handler) { + this.handler = handler; + } + + @Override + public void startElement(String uri, String localName, String qName, Attributes attrs) { + } + + @Override + public void endElement(String uri, String localName, String qName) { + if (equalsOrSuffix(qName, "DataCenter")) { + dataCenters.add(handler.getResult()); + } else { + handler.endElement(uri, localName, qName); + } + } + + @Override + public void characters(char ch[], int start, int length) { + handler.characters(ch, start, length); + } + +} diff --git a/common/trmk/src/main/java/org/jclouds/vcloud/terremark/xml/InternetServiceHandler.java b/common/trmk/src/main/java/org/jclouds/vcloud/terremark/xml/InternetServiceHandler.java index 14a5df50b9..d33b5c9da5 100644 --- a/common/trmk/src/main/java/org/jclouds/vcloud/terremark/xml/InternetServiceHandler.java +++ b/common/trmk/src/main/java/org/jclouds/vcloud/terremark/xml/InternetServiceHandler.java @@ -18,25 +18,22 @@ */ package org.jclouds.vcloud.terremark.xml; +import static org.jclouds.util.SaxUtils.currentOrNull; +import static org.jclouds.util.SaxUtils.equalsOrSuffix; + import java.net.URI; -import javax.annotation.Resource; - import org.jclouds.http.functions.ParseSax.HandlerWithResult; -import org.jclouds.logging.Logger; import org.jclouds.vcloud.terremark.domain.InternetService; import org.jclouds.vcloud.terremark.domain.Protocol; import org.jclouds.vcloud.terremark.domain.PublicIpAddress; import org.xml.sax.Attributes; -import org.xml.sax.SAXException; /** * @author Adrian Cole */ public class InternetServiceHandler extends HandlerWithResult { - @Resource - protected Logger logger = Logger.NULL; private StringBuilder currentText = new StringBuilder(); private boolean inPublicIpAddress; @@ -51,10 +48,9 @@ public class InternetServiceHandler extends HandlerWithResult { private boolean enabled; private Protocol protocol; - protected String currentOrNull() { - String returnVal = currentText.toString().trim(); - return returnVal.equals("") ? null : returnVal; - } + protected int depth = 0; + + private int thisDepth; @Override public InternetService getResult() { @@ -62,40 +58,48 @@ public class InternetServiceHandler extends HandlerWithResult { } @Override - public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException { - if (qName.equals("PublicIpAddress")) { + public void startElement(String uri, String localName, String qName, Attributes attrs) { + depth++; + if (equalsOrSuffix(qName, "InternetService")) { + thisDepth = depth; + } else if (equalsOrSuffix(qName, "PublicIpAddress")) { inPublicIpAddress = true; } } public void endElement(String uri, String name, String qName) { - String current = currentOrNull(); - if (qName.equals("PublicIpAddress")) { + depth--; + if (equalsOrSuffix(qName, "PublicIpAddress")) { + inPublicIpAddress = false; publicIpAddress = new PublicIpAddress(address, addressLocation); address = null; addressLocation = null; - inPublicIpAddress = false; - } else if (current != null) { - if (qName.equals("Href")) { - if (inPublicIpAddress) - addressLocation = URI.create(current); - else - location = URI.create(current); - } else if (qName.equals("Name")) { - if (inPublicIpAddress) - address = current; - else - serviceName = current; - } else if (qName.equals("Port")) { - port = Integer.parseInt(current); - } else if (qName.equals("Protocol")) { - protocol = Protocol.valueOf(current); - } else if (qName.equals("Enabled")) { - enabled = Boolean.parseBoolean(current); - } else if (qName.equals("Timeout")) { - timeout = Integer.parseInt(current); - } else if (qName.equals("Description")) { - description = current; + } else { + String value = currentOrNull(currentText); + if (value != null && !value.equals("")) { + if (depth == thisDepth) { + if (equalsOrSuffix(qName, "Href")) { + location = URI.create(value); + } else if (equalsOrSuffix(qName, "Name")) { + serviceName = value; + } else if (equalsOrSuffix(qName, "Port")) { + port = Integer.parseInt(value); + } else if (equalsOrSuffix(qName, "Protocol")) { + protocol = Protocol.valueOf(value); + } else if (equalsOrSuffix(qName, "Enabled")) { + enabled = Boolean.parseBoolean(value); + } else if (equalsOrSuffix(qName, "Timeout")) { + timeout = Integer.parseInt(value); + } else if (equalsOrSuffix(qName, "Description")) { + description = currentOrNull(currentText); + } + } else if (inPublicIpAddress) { + if (equalsOrSuffix(qName, "Href")) { + addressLocation = URI.create(value); + } else if (equalsOrSuffix(qName, "Name")) { + address = value; + } + } } } currentText = new StringBuilder(); diff --git a/common/trmk/src/main/java/org/jclouds/vcloud/terremark/xml/InternetServicesHandler.java b/common/trmk/src/main/java/org/jclouds/vcloud/terremark/xml/InternetServicesHandler.java index ff16d9ac67..43953793e7 100644 --- a/common/trmk/src/main/java/org/jclouds/vcloud/terremark/xml/InternetServicesHandler.java +++ b/common/trmk/src/main/java/org/jclouds/vcloud/terremark/xml/InternetServicesHandler.java @@ -18,28 +18,26 @@ */ package org.jclouds.vcloud.terremark.xml; +import static org.jclouds.util.SaxUtils.equalsOrSuffix; + import java.util.Set; -import javax.annotation.Resource; import javax.inject.Inject; import org.jclouds.http.functions.ParseSax.HandlerWithResult; -import org.jclouds.logging.Logger; import org.jclouds.vcloud.terremark.domain.InternetService; import org.xml.sax.Attributes; -import org.xml.sax.SAXException; -import com.google.common.collect.Sets; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.ImmutableSet.Builder; /** * @author Adrian Cole */ public class InternetServicesHandler extends HandlerWithResult> { - @Resource - protected Logger logger = Logger.NULL; private final InternetServiceHandler handler; - Set result = Sets.newLinkedHashSet(); + private Builder builder = ImmutableSet. builder(); @Inject public InternetServicesHandler(InternetServiceHandler handler) { @@ -48,24 +46,44 @@ public class InternetServicesHandler extends HandlerWithResult getResult() { - return result; + try { + return builder.build(); + } finally { + builder = ImmutableSet. builder(); + } } + int depth; + private boolean inInternetService; + @Override - public void startElement(String uri, String localName, String qName, Attributes attributes) - throws SAXException { - handler.startElement(uri, localName, qName, attributes); + public void startElement(String uri, String localName, String qName, Attributes attrs) { + depth++; + if (depth == 2) { + if (equalsOrSuffix(qName, "InternetService")) { + inInternetService = true; + } + } else if (inInternetService) { + handler.startElement(uri, localName, qName, attrs); + } } public void endElement(String uri, String name, String qName) { - handler.endElement(uri, name, qName); - if (qName.equals("InternetService")) { - result.add(handler.getResult()); + depth--; + if (depth == 1) { + if (equalsOrSuffix(qName, "InternetService")) { + inInternetService = false; + builder.add(handler.getResult()); + } + } else if (inInternetService) { + handler.endElement(uri, name, qName); } } public void characters(char ch[], int start, int length) { - handler.characters(ch, start, length); + if (inInternetService) { + handler.characters(ch, start, length); + } } } \ No newline at end of file diff --git a/common/trmk/src/main/java/org/jclouds/vcloud/terremark/xml/TerremarkOrgHandler.java b/common/trmk/src/main/java/org/jclouds/vcloud/terremark/xml/TerremarkOrgHandler.java index 26f3bba76c..8bc95ab095 100644 --- a/common/trmk/src/main/java/org/jclouds/vcloud/terremark/xml/TerremarkOrgHandler.java +++ b/common/trmk/src/main/java/org/jclouds/vcloud/terremark/xml/TerremarkOrgHandler.java @@ -18,13 +18,14 @@ */ package org.jclouds.vcloud.terremark.xml; -import static org.jclouds.util.SaxUtils.cleanseAttributes; import static org.jclouds.vcloud.util.Utils.newReferenceType; +import static org.jclouds.vcloud.util.Utils.putReferenceType; import java.util.Map; import javax.inject.Inject; +import org.jclouds.util.SaxUtils; import org.jclouds.vcloud.domain.ReferenceType; import org.jclouds.vcloud.terremark.domain.TerremarkOrg; import org.jclouds.vcloud.terremark.domain.internal.TerremarkOrgImpl; @@ -33,6 +34,8 @@ import org.jclouds.vcloud.xml.TaskHandler; import org.xml.sax.Attributes; import org.xml.sax.SAXException; +import com.google.common.collect.Maps; + /** * @author Adrian Cole */ @@ -42,24 +45,37 @@ public class TerremarkOrgHandler extends OrgHandler { super(taskHandler); } - private ReferenceType keysList; + protected ReferenceType keysList; + protected Map tasksLists = Maps.newLinkedHashMap(); public TerremarkOrg getResult() { return new TerremarkOrgImpl(org.getName(), org.getType(), org.getHref(), description, catalogs, vdcs, networks, - tasksList, keysList); + tasksLists, keysList); } @Override public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException { - Map attributes = cleanseAttributes(attrs); - super.startElement(uri, localName, qName, attrs); - if (qName.equals("Link")) { - if (attributes.containsKey("type")) { - String type = attributes.get("type"); - if (type != null && type.endsWith("keysList+xml")) { - keysList = newReferenceType(attributes); + Map attributes = SaxUtils.cleanseAttributes(attrs); + if (qName.endsWith("Org")) { + org = newReferenceType(attributes); + } else if (qName.endsWith("Link")) { + String type = attributes.get("type"); + if (type != null) { + if (type.indexOf("vdc+xml") != -1) { + putReferenceType(vdcs, attributes); + } else if (type.indexOf("catalog+xml") != -1) { + putReferenceType(catalogs, attributes); + } else if (type.indexOf("tasksList+xml") != -1) { + putReferenceType(tasksLists, attributes); + } else if (type.indexOf("network+xml") != -1) { + putReferenceType(networks, attributes); + } else if (type != null && type.endsWith("keysList+xml")) { + keysList = newReferenceType(attributes); } } + } else { + taskHandler.startElement(uri, localName, qName, attrs); } + } } diff --git a/common/trmk/src/main/java/org/jclouds/vcloud/terremark/xml/VAppExtendedInfoHandler.java b/common/trmk/src/main/java/org/jclouds/vcloud/terremark/xml/VAppExtendedInfoHandler.java index 5bf429f6fd..0ed53cf5ba 100644 --- a/common/trmk/src/main/java/org/jclouds/vcloud/terremark/xml/VAppExtendedInfoHandler.java +++ b/common/trmk/src/main/java/org/jclouds/vcloud/terremark/xml/VAppExtendedInfoHandler.java @@ -20,16 +20,15 @@ package org.jclouds.vcloud.terremark.xml; import java.net.URI; import java.util.Arrays; -import java.util.ArrayList; import java.util.List; import javax.annotation.Resource; import org.jclouds.http.functions.ParseSax.HandlerWithResult; import org.jclouds.logging.Logger; -import org.jclouds.vcloud.terremark.domain.VAppExtendedInfo; import org.jclouds.vcloud.terremark.domain.NetworkAdapter; import org.jclouds.vcloud.terremark.domain.Subnet; +import org.jclouds.vcloud.terremark.domain.VAppExtendedInfo; import org.xml.sax.Attributes; import org.xml.sax.SAXException; diff --git a/common/trmk/src/test/java/org/jclouds/vcloud/terremark/BaseTerremarkClientLiveTest.java b/common/trmk/src/test/java/org/jclouds/vcloud/terremark/BaseTerremarkClientLiveTest.java new file mode 100644 index 0000000000..1c25431a42 --- /dev/null +++ b/common/trmk/src/test/java/org/jclouds/vcloud/terremark/BaseTerremarkClientLiveTest.java @@ -0,0 +1,115 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.jclouds.vcloud.terremark; + +import static com.google.common.base.Preconditions.checkNotNull; + +import java.util.Properties; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.TimeoutException; + +import org.jclouds.Constants; +import org.jclouds.compute.ComputeService; +import org.jclouds.compute.ComputeServiceContextFactory; +import org.jclouds.logging.log4j.config.Log4JLoggingModule; +import org.jclouds.net.IPSocket; +import org.jclouds.predicates.InetSocketAddressConnect; +import org.jclouds.predicates.RetryablePredicate; +import org.jclouds.rest.RestContextFactory; +import org.jclouds.ssh.SshClient.Factory; +import org.jclouds.ssh.jsch.config.JschSshClientModule; +import org.testng.annotations.AfterGroups; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.BeforeGroups; +import org.testng.annotations.Test; + +import com.google.common.collect.ImmutableSet; +import com.google.inject.Guice; +import com.google.inject.Module; + +/** + * + * @author Adrian Cole + */ +@Test(groups = "live", enabled = true, singleThreaded = true) +public abstract class BaseTerremarkClientLiveTest { + protected String prefix = System.getProperty("user.name"); + + protected ComputeService client; + + protected String provider = "trmk-ecloud"; + protected String identity; + protected String credential; + protected String endpoint; + protected String apiversion; + + protected RetryablePredicate socketTester; + protected Factory sshFactory; + + @SuppressWarnings("unchecked") + protected T getApi() { + return (T) client.getContext().getProviderSpecificContext().getApi(); + } + + @BeforeClass + protected void setupCredentials() { + identity = checkNotNull(System.getProperty("test." + provider + ".identity"), "test." + provider + ".identity"); + credential = System.getProperty("test." + provider + ".credential"); + endpoint = System.getProperty("test." + provider + ".endpoint"); + apiversion = System.getProperty("test." + provider + ".apiversion"); + } + + protected Properties setupProperties() { + Properties overrides = new Properties(); + overrides.setProperty(Constants.PROPERTY_TRUST_ALL_CERTS, "true"); + overrides.setProperty(Constants.PROPERTY_RELAX_HOSTNAME, "true"); + overrides.setProperty(provider + ".identity", identity); + if (credential != null) + overrides.setProperty(provider + ".credential", credential); + if (endpoint != null) + overrides.setProperty(provider + ".endpoint", endpoint); + if (apiversion != null) + overrides.setProperty(provider + ".apiversion", apiversion); + return overrides; + } + + @BeforeGroups(groups = { "live" }) + public void setupClient() { + setupCredentials(); + Properties overrides = setupProperties(); + client = new ComputeServiceContextFactory().createContext(provider, + ImmutableSet. of(new Log4JLoggingModule()), overrides).getComputeService(); + socketTester = new RetryablePredicate(new InetSocketAddressConnect(), 300, 1, TimeUnit.SECONDS); + sshFactory = Guice.createInjector(getSshModule()).getInstance(Factory.class); + } + + protected Properties setupRestProperties() { + return RestContextFactory.getPropertiesFromResource("/rest.properties"); + } + + protected JschSshClientModule getSshModule() { + return new JschSshClientModule(); + } + + @AfterGroups(groups = { "live" }) + protected void cleanup() throws InterruptedException, ExecutionException, TimeoutException { + client.getContext().close(); + } +} \ No newline at end of file diff --git a/common/trmk/src/test/java/org/jclouds/vcloud/terremark/TerremarkClientLiveTest.java b/common/trmk/src/test/java/org/jclouds/vcloud/terremark/TerremarkClientLiveTest.java index 8fbdcf132a..74d6934adf 100644 --- a/common/trmk/src/test/java/org/jclouds/vcloud/terremark/TerremarkClientLiveTest.java +++ b/common/trmk/src/test/java/org/jclouds/vcloud/terremark/TerremarkClientLiveTest.java @@ -31,9 +31,9 @@ import static org.testng.Assert.assertNotNull; import java.io.IOException; import java.net.URI; import java.util.List; +import java.util.Map.Entry; import java.util.Properties; import java.util.Set; -import java.util.Map.Entry; import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; @@ -48,8 +48,8 @@ import org.jclouds.predicates.RetryablePredicate; import org.jclouds.predicates.SocketOpen; import org.jclouds.rest.RestContextFactory; import org.jclouds.ssh.SshClient; -import org.jclouds.ssh.SshException; import org.jclouds.ssh.SshClient.Factory; +import org.jclouds.ssh.SshException; import org.jclouds.ssh.jsch.config.JschSshClientModule; import org.jclouds.vcloud.VCloudExpressClientLiveTest; import org.jclouds.vcloud.VCloudExpressMediaType; @@ -99,7 +99,14 @@ public abstract class TerremarkClientLiveTest extends VCloudExpressClientLiveTes protected VCloudExpressVApp clone; protected VDC vdc; public static final String PREFIX = System.getProperty("user.name") + "-terremark"; - + + @Test + public void testListOrgs() throws Exception { + for (ReferenceType org : tmClient.listOrgs()) { + assertNotNull(tmClient.getOrg(org.getHref())); + } + } + @Test public void testGetAllInternetServices() throws Exception { for (InternetService service : tmClient.getAllInternetServicesInVDC(tmClient.findVDCInOrgNamed(null, null) diff --git a/common/trmk/src/test/java/org/jclouds/vcloud/terremark/xml/DataCenterHandlerTest.java b/common/trmk/src/test/java/org/jclouds/vcloud/terremark/xml/DataCenterHandlerTest.java new file mode 100644 index 0000000000..cc083dc048 --- /dev/null +++ b/common/trmk/src/test/java/org/jclouds/vcloud/terremark/xml/DataCenterHandlerTest.java @@ -0,0 +1,47 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.jclouds.vcloud.terremark.xml; + +import static org.testng.Assert.assertEquals; + +import java.io.InputStream; + +import org.jclouds.http.functions.BaseHandlerTest; +import org.jclouds.vcloud.terremark.domain.DataCenter; +import org.testng.annotations.Test; + +/** + * Tests behavior of {@code DataCenterHandler} + * + * @author Adrian Cole + */ +// NOTE:without testName, this will not call @Before* and fail w/NPE during +// surefire +@Test(groups = "unit", testName = "DataCenterHandlerTest") +public class DataCenterHandlerTest extends BaseHandlerTest { + + public void test() { + InputStream is = getClass().getResourceAsStream("/datacenter.xml"); + + DataCenter result = factory.create(injector.getInstance(DataCenterHandler.class)).parse(is); + + DataCenter expects = DataCenter.builder().id("1").name("Terremark - Miami").code("MIA").build(); + assertEquals(result.toString(), expects.toString()); + } +} diff --git a/common/trmk/src/test/java/org/jclouds/vcloud/terremark/xml/DataCentersHandlerTest.java b/common/trmk/src/test/java/org/jclouds/vcloud/terremark/xml/DataCentersHandlerTest.java new file mode 100644 index 0000000000..f062d0eabd --- /dev/null +++ b/common/trmk/src/test/java/org/jclouds/vcloud/terremark/xml/DataCentersHandlerTest.java @@ -0,0 +1,52 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.jclouds.vcloud.terremark.xml; + +import static org.testng.Assert.assertEquals; + +import java.io.InputStream; +import java.util.Set; + +import org.jclouds.http.functions.BaseHandlerTest; +import org.jclouds.vcloud.terremark.domain.DataCenter; +import org.testng.annotations.Test; + +import com.google.common.collect.ImmutableSet; + +/** + * Tests behavior of {@code DataCentersHandler} + * + * @author Adrian Cole + */ +// NOTE:without testName, this will not call @Before* and fail w/NPE during +// surefire +@Test(groups = "unit", testName = "DataCentersHandlerTest") +public class DataCentersHandlerTest extends BaseHandlerTest { + + public void test() { + InputStream is = getClass().getResourceAsStream("/datacenters.xml"); + + Set result = factory.create(injector.getInstance(DataCentersHandler.class)).parse(is); + + ImmutableSet expects = ImmutableSet.of(DataCenter.builder().id("1").name("Terremark - Miami").code("MIA").build(), + DataCenter.builder().id("3670").name("Terremark - Culpeper").code("CUA").build()); + assertEquals(result.toString(), expects.toString()); + } + +} diff --git a/common/trmk/src/test/java/org/jclouds/vcloud/terremark/xml/InternetServicesHandlerTest.java b/common/trmk/src/test/java/org/jclouds/vcloud/terremark/xml/InternetServicesHandlerTest.java index 5e82e09b92..1e214809c9 100644 --- a/common/trmk/src/test/java/org/jclouds/vcloud/terremark/xml/InternetServicesHandlerTest.java +++ b/common/trmk/src/test/java/org/jclouds/vcloud/terremark/xml/InternetServicesHandlerTest.java @@ -46,11 +46,11 @@ public class InternetServicesHandlerTest extends BaseHandlerTest { InputStream is = getClass().getResourceAsStream("/terremark/InternetServices.xml"); Set result = factory.create(injector.getInstance(InternetServicesHandler.class)).parse(is); - assertEquals(result, ImmutableSet.of(new InternetService("IS_for_Jim2", URI + assertEquals(result.toString(), ImmutableSet.of(new InternetService("IS_for_Jim2", URI .create("https://services.vcloudexpress.terremark.com/api/v0.8/InternetServices/524"), new PublicIpAddress("10.1.22.159", URI .create("https://services.vcloudexpress.terremark.com/api/v0.8/PublicIps/4208")), 45, - Protocol.HTTP, false, 1, "Some test service"))); + Protocol.HTTP, false, 1, "Some test service")).toString()); } public void test2() throws UnknownHostException { diff --git a/common/trmk/src/test/java/org/jclouds/vcloud/terremark/xml/TerremarkOrgHandlerTest.java b/common/trmk/src/test/java/org/jclouds/vcloud/terremark/xml/TerremarkOrgHandlerTest.java index 6731cc86c9..2a51fdb35e 100644 --- a/common/trmk/src/test/java/org/jclouds/vcloud/terremark/xml/TerremarkOrgHandlerTest.java +++ b/common/trmk/src/test/java/org/jclouds/vcloud/terremark/xml/TerremarkOrgHandlerTest.java @@ -78,9 +78,11 @@ public class TerremarkOrgHandlerTest extends BaseHandlerTest { assertEquals(result.getVDCs(), ImmutableMap.of("Miami Environment 1", new ReferenceTypeImpl( "Miami Environment 1", VCloudExpressMediaType.VDC_XML, URI .create("https://services.vcloudexpress.terremark.com/api/v0.8a-ext1.6/vdc/32")))); - assertEquals(result.getTasksList(), new ReferenceTypeImpl("Miami Environment 1 Tasks List", TASKSLIST_XML, URI - .create("https://services.vcloudexpress.terremark.com/api/v0.8a-ext1.6/vdc/32/tasksList"))); - assertEquals(result.getKeysList(), new ReferenceTypeImpl("Keys", "application/vnd.tmrk.vcloudExpress.keysList+xml", + assertEquals(result.getTasksLists(), ImmutableMap.of( + "Miami Environment 1 Tasks List", + new ReferenceTypeImpl("Miami Environment 1 Tasks List", TASKSLIST_XML, URI + .create("https://services.vcloudexpress.terremark.com/api/v0.8a-ext1.6/vdc/32/tasksList")))); + assertEquals(result.getKeys(), new ReferenceTypeImpl("Keys", "application/vnd.tmrk.vcloudExpress.keysList+xml", URI.create("https://services.vcloudexpress.terremark.com/api/v0.8a-ext1.6/extensions/org/48/keys"))); } diff --git a/common/trmk/src/test/resources/datacenter.xml b/common/trmk/src/test/resources/datacenter.xml new file mode 100644 index 0000000000..aba474e509 --- /dev/null +++ b/common/trmk/src/test/resources/datacenter.xml @@ -0,0 +1,9 @@ + + + MIA + + 1 + + Terremark - Miami + + \ No newline at end of file diff --git a/common/trmk/src/test/resources/datacenters.xml b/common/trmk/src/test/resources/datacenters.xml new file mode 100644 index 0000000000..34aee404f8 --- /dev/null +++ b/common/trmk/src/test/resources/datacenters.xml @@ -0,0 +1,23 @@ + + + + + MIA + + 1 + + Terremark - Miami + + + + + + CUA + + 3670 + + Terremark - Culpeper + + + + \ No newline at end of file diff --git a/compute/src/test/clojure/org/jclouds/compute_test.clj b/compute/src/test/clojure/org/jclouds/compute_test.clj index f47e0cff19..bb372fe69d 100644 --- a/compute/src/test/clojure/org/jclouds/compute_test.clj +++ b/compute/src/test/clojure/org/jclouds/compute_test.clj @@ -54,7 +54,6 @@ list, Alan Dipert and MeikelBrandmeyer." (is (compute-service? (as-compute-service (compute-context *compute*))))) (deftest nodes-test - (is (empty? (nodes))) (is (create-node "fred" (build-template *compute* {} ))) (is (= 1 (count (nodes)))) diff --git a/providers/trmk-ecloud/pom.xml b/providers/trmk-ecloud/pom.xml index 84fdebe991..0d6fbca333 100644 --- a/providers/trmk-ecloud/pom.xml +++ b/providers/trmk-ecloud/pom.xml @@ -159,7 +159,7 @@ ${project.artifactId} - org.jclouds.vcloud.terremark.*;version="${project.version}" + org.jclouds.vcloud.terremark.*;version="${project.version}",org.jclouds.terremark.ecloud.*;version="${project.version}" org.jclouds.*;version="${project.version}",* diff --git a/providers/trmk-ecloud/src/main/java/org/jclouds/terremark/ecloud/domain/TerremarkECloudOrg.java b/providers/trmk-ecloud/src/main/java/org/jclouds/terremark/ecloud/domain/TerremarkECloudOrg.java new file mode 100644 index 0000000000..a0b5028a93 --- /dev/null +++ b/providers/trmk-ecloud/src/main/java/org/jclouds/terremark/ecloud/domain/TerremarkECloudOrg.java @@ -0,0 +1,27 @@ +package org.jclouds.terremark.ecloud.domain; + +import org.jclouds.vcloud.domain.ReferenceType; +import org.jclouds.vcloud.terremark.domain.TerremarkOrg; +import org.jclouds.vcloud.terremark.domain.internal.TerremarkOrgImpl; +import org.jclouds.vcloud.terremark.endpoints.DataCenters; +import org.jclouds.vcloud.terremark.endpoints.Tags; +import org.jclouds.vcloud.terremark.endpoints.VAppCatalog; + +import com.google.inject.ImplementedBy; + +/** + * @author Adrian Cole + */ +@org.jclouds.vcloud.endpoints.Org +@ImplementedBy(TerremarkOrgImpl.class) +public interface TerremarkECloudOrg extends TerremarkOrg { + + @DataCenters + ReferenceType getDataCenters(); + + @Tags + ReferenceType getTags(); + + @VAppCatalog + ReferenceType getVAppCatalog(); +} \ No newline at end of file diff --git a/providers/trmk-ecloud/src/main/java/org/jclouds/terremark/ecloud/domain/internal/TerremarkECloudOrgImpl.java b/providers/trmk-ecloud/src/main/java/org/jclouds/terremark/ecloud/domain/internal/TerremarkECloudOrgImpl.java new file mode 100644 index 0000000000..1a75fb8834 --- /dev/null +++ b/providers/trmk-ecloud/src/main/java/org/jclouds/terremark/ecloud/domain/internal/TerremarkECloudOrgImpl.java @@ -0,0 +1,67 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.jclouds.terremark.ecloud.domain.internal; + +import static com.google.common.base.Preconditions.checkNotNull; + +import java.net.URI; +import java.util.Map; + +import org.jclouds.terremark.ecloud.domain.TerremarkECloudOrg; +import org.jclouds.vcloud.domain.ReferenceType; +import org.jclouds.vcloud.terremark.domain.internal.TerremarkOrgImpl; + +/** + * Locations of resources in a Terremark eCloud Org + * + * @author Adrian Cole + * + */ +public class TerremarkECloudOrgImpl extends TerremarkOrgImpl implements TerremarkECloudOrg { + + private final ReferenceType dataCentersList; + private final ReferenceType deviceTags; + private final ReferenceType vAppCatalog; + + public TerremarkECloudOrgImpl(String name, String type, URI id, String description, + Map catalogs, Map vdcs, Map networks, + Map tasksLists, ReferenceType keysList, ReferenceType deviceTags, + ReferenceType vAppCatalog, ReferenceType dataCentersList) { + super(name, type, id, name, catalogs, vdcs, networks, tasksLists, keysList); + this.deviceTags = checkNotNull(deviceTags, "deviceTags"); + this.vAppCatalog = checkNotNull(vAppCatalog, "vAppCatalog"); + this.dataCentersList = checkNotNull(dataCentersList, "dataCentersList"); + } + + @Override + public ReferenceType getDataCenters() { + return dataCentersList; + } + + @Override + public ReferenceType getTags() { + return deviceTags; + } + + @Override + public ReferenceType getVAppCatalog() { + return vAppCatalog; + } + +} \ No newline at end of file diff --git a/providers/trmk-ecloud/src/main/java/org/jclouds/terremark/ecloud/features/DataCenterOperationsAsyncClient.java b/providers/trmk-ecloud/src/main/java/org/jclouds/terremark/ecloud/features/DataCenterOperationsAsyncClient.java new file mode 100644 index 0000000000..cfac8b7fd0 --- /dev/null +++ b/providers/trmk-ecloud/src/main/java/org/jclouds/terremark/ecloud/features/DataCenterOperationsAsyncClient.java @@ -0,0 +1,55 @@ +package org.jclouds.terremark.ecloud.features; + +import static org.jclouds.vcloud.terremark.TerremarkECloudMediaType.DATACENTERSLIST_XML; + +import java.net.URI; +import java.util.Set; + +import javax.annotation.Nullable; +import javax.ws.rs.Consumes; +import javax.ws.rs.GET; + +import org.jclouds.rest.annotations.EndpointParam; +import org.jclouds.rest.annotations.ExceptionParser; +import org.jclouds.rest.annotations.RequestFilters; +import org.jclouds.rest.annotations.XMLResponseParser; +import org.jclouds.rest.functions.ReturnEmptySetOnNotFoundOr404; +import org.jclouds.terremark.ecloud.functions.OrgURIToDataCentersListEndpoint; +import org.jclouds.vcloud.filters.SetVCloudTokenCookie; +import org.jclouds.vcloud.terremark.domain.DataCenter; +import org.jclouds.vcloud.terremark.domain.KeyPair; +import org.jclouds.vcloud.terremark.xml.DataCentersHandler; + +import com.google.common.util.concurrent.ListenableFuture; + +/** + * + * @see + * @see DataCenterOperationsClient + * + * @author Adrian Cole + */ +@RequestFilters(SetVCloudTokenCookie.class) +public interface DataCenterOperationsAsyncClient { + + /** + * @see DataCenterOperationsClient#listDataCentersInOrg + */ + @GET + @Consumes(DATACENTERSLIST_XML) + @XMLResponseParser(DataCentersHandler.class) + @ExceptionParser(ReturnEmptySetOnNotFoundOr404.class) + ListenableFuture> listDataCentersInOrg( + @Nullable @EndpointParam(parser = OrgURIToDataCentersListEndpoint.class) URI org); + + /** + * @see DataCenterOperationsClient#listDataCenters + */ + @GET + @Consumes(DATACENTERSLIST_XML) + @XMLResponseParser(DataCentersHandler.class) + @ExceptionParser(ReturnEmptySetOnNotFoundOr404.class) + ListenableFuture> listDataCenters(@EndpointParam URI dataCenters); +} diff --git a/providers/trmk-ecloud/src/main/java/org/jclouds/terremark/ecloud/features/DataCenterOperationsClient.java b/providers/trmk-ecloud/src/main/java/org/jclouds/terremark/ecloud/features/DataCenterOperationsClient.java new file mode 100644 index 0000000000..fcaf3cc5a7 --- /dev/null +++ b/providers/trmk-ecloud/src/main/java/org/jclouds/terremark/ecloud/features/DataCenterOperationsClient.java @@ -0,0 +1,40 @@ +package org.jclouds.terremark.ecloud.features; + +import java.net.URI; +import java.util.Set; +import java.util.concurrent.TimeUnit; + +import org.jclouds.concurrent.Timeout; +import org.jclouds.vcloud.terremark.domain.DataCenter; + +/** + * Data Center Operations access to DataCenterOperations functionality in vCloud + *

    + * There are times where knowing a data center is necessary to complete certain + * operations (i.e. uploading a catalog item). The data centers for an + * organization are those data centers that contain at least one of the + * organization's environments. + * + * @see DataCenterOperationsAsyncClient + * @author Adrian Cole + */ +@Timeout(duration = 300, timeUnit = TimeUnit.SECONDS) +public interface DataCenterOperationsClient { + + /** + * This call will get the list of data centers that contain at least one of + * the organization's environments. + * + * + * @return data centers + */ + Set listDataCentersInOrg(URI orgId); + + /** + * This call will get the list of data centers by list id. + * + * @return data centers + */ + Set listDataCenters(URI dataCentersList); + +} diff --git a/providers/trmk-ecloud/src/main/java/org/jclouds/terremark/ecloud/features/TagOperationsAsyncClient.java b/providers/trmk-ecloud/src/main/java/org/jclouds/terremark/ecloud/features/TagOperationsAsyncClient.java new file mode 100644 index 0000000000..fc6d5b97ac --- /dev/null +++ b/providers/trmk-ecloud/src/main/java/org/jclouds/terremark/ecloud/features/TagOperationsAsyncClient.java @@ -0,0 +1,53 @@ +package org.jclouds.terremark.ecloud.features; + +import static org.jclouds.vcloud.terremark.TerremarkECloudMediaType.TAGSLISTLIST_XML; + +import java.net.URI; +import java.util.Map; + +import javax.annotation.Nullable; +import javax.ws.rs.Consumes; +import javax.ws.rs.GET; + +import org.jclouds.rest.annotations.EndpointParam; +import org.jclouds.rest.annotations.ExceptionParser; +import org.jclouds.rest.annotations.RequestFilters; +import org.jclouds.rest.annotations.XMLResponseParser; +import org.jclouds.rest.functions.ReturnEmptyMapOnNotFoundOr404; +import org.jclouds.terremark.ecloud.functions.OrgURIToTagsListEndpoint; +import org.jclouds.terremark.ecloud.xml.TagNameToUsageCountHandler; +import org.jclouds.vcloud.filters.SetVCloudTokenCookie; + +import com.google.common.util.concurrent.ListenableFuture; + +/** + * + * @see + * @see TagOperationsClient + * + * @author Adrian Cole + */ +@RequestFilters(SetVCloudTokenCookie.class) +public interface TagOperationsAsyncClient { + + /** + * @see TagOperationsClient#getTagNameToUsageCountInOrg + */ + @GET + @Consumes(TAGSLISTLIST_XML) + @XMLResponseParser(TagNameToUsageCountHandler.class) + @ExceptionParser(ReturnEmptyMapOnNotFoundOr404.class) + ListenableFuture> getTagNameToUsageCountInOrg( + @Nullable @EndpointParam(parser = OrgURIToTagsListEndpoint.class) URI org); + + /** + * @see TagOperationsClient#getTagNameToUsageCount + */ + @GET + @Consumes(TAGSLISTLIST_XML) + @XMLResponseParser(TagNameToUsageCountHandler.class) + @ExceptionParser(ReturnEmptyMapOnNotFoundOr404.class) + ListenableFuture> getTagNameToUsageCount(@EndpointParam URI tagList); +} diff --git a/providers/trmk-ecloud/src/main/java/org/jclouds/terremark/ecloud/features/TagOperationsClient.java b/providers/trmk-ecloud/src/main/java/org/jclouds/terremark/ecloud/features/TagOperationsClient.java new file mode 100644 index 0000000000..a17762b7bd --- /dev/null +++ b/providers/trmk-ecloud/src/main/java/org/jclouds/terremark/ecloud/features/TagOperationsClient.java @@ -0,0 +1,33 @@ +package org.jclouds.terremark.ecloud.features; + +import java.net.URI; +import java.util.Map; +import java.util.concurrent.TimeUnit; + +import org.jclouds.concurrent.Timeout; + +/** + * Tag Based Operations + *

    + * + * @see TagOperationsAsyncClient + * @author Adrian Cole + */ +@Timeout(duration = 300, timeUnit = TimeUnit.SECONDS) +public interface TagOperationsClient { + + /** + * This call returns the list of all tags belonging to the organization. + * + * @return tags + */ + Map getTagNameToUsageCountInOrg(URI orgId); + + /** + * This call returns the list of all tags by list id. + * + * @return tags + */ + Map getTagNameToUsageCount(URI tagsList); + +} diff --git a/providers/trmk-ecloud/src/main/java/org/jclouds/terremark/ecloud/functions/OrgURIToDataCentersListEndpoint.java b/providers/trmk-ecloud/src/main/java/org/jclouds/terremark/ecloud/functions/OrgURIToDataCentersListEndpoint.java new file mode 100644 index 0000000000..97c9b2281f --- /dev/null +++ b/providers/trmk-ecloud/src/main/java/org/jclouds/terremark/ecloud/functions/OrgURIToDataCentersListEndpoint.java @@ -0,0 +1,51 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.jclouds.terremark.ecloud.functions; + +import java.net.URI; +import java.util.Map; + +import javax.inject.Inject; +import javax.inject.Singleton; + +import org.jclouds.terremark.ecloud.domain.TerremarkECloudOrg; +import org.jclouds.vcloud.domain.Org; +import org.jclouds.vcloud.terremark.domain.TerremarkOrg; +import org.jclouds.vcloud.terremark.functions.OrgURIToEndpoint; + +import com.google.common.base.Function; +import com.google.common.base.Supplier; + +/** + * + * @author Adrian Cole + */ +@Singleton +public class OrgURIToDataCentersListEndpoint extends OrgURIToEndpoint implements Function { + @Inject + public OrgURIToDataCentersListEndpoint(Supplier> orgMap, + @org.jclouds.vcloud.endpoints.Org URI defaultUri) { + super(orgMap, defaultUri); + } + + public URI getUriFromOrg(TerremarkOrg org) { + return TerremarkECloudOrg.class.cast(org).getDataCenters().getHref(); + } + +} \ No newline at end of file diff --git a/providers/trmk-ecloud/src/main/java/org/jclouds/terremark/ecloud/functions/OrgURIToTagsListEndpoint.java b/providers/trmk-ecloud/src/main/java/org/jclouds/terremark/ecloud/functions/OrgURIToTagsListEndpoint.java new file mode 100644 index 0000000000..aeb35daffe --- /dev/null +++ b/providers/trmk-ecloud/src/main/java/org/jclouds/terremark/ecloud/functions/OrgURIToTagsListEndpoint.java @@ -0,0 +1,51 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.jclouds.terremark.ecloud.functions; + +import java.net.URI; +import java.util.Map; + +import javax.inject.Inject; +import javax.inject.Singleton; + +import org.jclouds.terremark.ecloud.domain.TerremarkECloudOrg; +import org.jclouds.vcloud.domain.Org; +import org.jclouds.vcloud.terremark.domain.TerremarkOrg; +import org.jclouds.vcloud.terremark.functions.OrgURIToEndpoint; + +import com.google.common.base.Function; +import com.google.common.base.Supplier; + +/** + * + * @author Adrian Cole + */ +@Singleton +public class OrgURIToTagsListEndpoint extends OrgURIToEndpoint implements Function { + @Inject + public OrgURIToTagsListEndpoint(Supplier> orgMap, + @org.jclouds.vcloud.endpoints.Org URI defaultUri) { + super(orgMap, defaultUri); + } + + public URI getUriFromOrg(TerremarkOrg org) { + return TerremarkECloudOrg.class.cast(org).getTags().getHref(); + } + +} \ No newline at end of file diff --git a/providers/trmk-ecloud/src/main/java/org/jclouds/terremark/ecloud/xml/TagNameToUsageCountHandler.java b/providers/trmk-ecloud/src/main/java/org/jclouds/terremark/ecloud/xml/TagNameToUsageCountHandler.java new file mode 100644 index 0000000000..c73fb8b4f1 --- /dev/null +++ b/providers/trmk-ecloud/src/main/java/org/jclouds/terremark/ecloud/xml/TagNameToUsageCountHandler.java @@ -0,0 +1,61 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.jclouds.terremark.ecloud.xml; + +import static org.jclouds.util.SaxUtils.currentOrNull; +import static org.jclouds.util.SaxUtils.equalsOrSuffix; + +import java.util.Map; + +import org.jclouds.http.functions.ParseSax; + +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableMap.Builder; + +/** + * @author Adrian Cole + */ +public class TagNameToUsageCountHandler extends ParseSax.HandlerWithResult> { + protected StringBuilder currentText = new StringBuilder(); + + private Builder builder = ImmutableMap. builder(); + private String name; + + public Map getResult() { + try { + return builder.build(); + } finally { + builder = ImmutableMap. builder(); + } + } + + @Override + public void endElement(String uri, String localName, String qName) { + if (equalsOrSuffix(qName, "Name")) { + name = currentOrNull(currentText); + } else if (equalsOrSuffix(qName, "UsageCount")) { + builder.put(name, new Integer(currentOrNull(currentText))); + } + currentText = new StringBuilder(); + } + + public void characters(char ch[], int start, int length) { + currentText.append(ch, start, length); + } +} diff --git a/providers/trmk-ecloud/src/main/java/org/jclouds/terremark/ecloud/xml/TerremarkECloudOrgHandler.java b/providers/trmk-ecloud/src/main/java/org/jclouds/terremark/ecloud/xml/TerremarkECloudOrgHandler.java new file mode 100644 index 0000000000..077220e148 --- /dev/null +++ b/providers/trmk-ecloud/src/main/java/org/jclouds/terremark/ecloud/xml/TerremarkECloudOrgHandler.java @@ -0,0 +1,71 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.jclouds.terremark.ecloud.xml; + +import static org.jclouds.util.SaxUtils.cleanseAttributes; +import static org.jclouds.vcloud.util.Utils.newReferenceType; + +import java.util.Map; + +import javax.inject.Inject; + +import org.jclouds.terremark.ecloud.domain.TerremarkECloudOrg; +import org.jclouds.terremark.ecloud.domain.internal.TerremarkECloudOrgImpl; +import org.jclouds.vcloud.domain.ReferenceType; +import org.jclouds.vcloud.terremark.xml.TerremarkOrgHandler; +import org.jclouds.vcloud.xml.TaskHandler; +import org.xml.sax.Attributes; +import org.xml.sax.SAXException; + +/** + * @author Adrian Cole + */ +public class TerremarkECloudOrgHandler extends TerremarkOrgHandler { + @Inject + public TerremarkECloudOrgHandler(TaskHandler taskHandler) { + super(taskHandler); + } + + private ReferenceType dataCentersList; + private ReferenceType deviceTags; + private ReferenceType vAppCatalog; + + public TerremarkECloudOrg getResult() { + return new TerremarkECloudOrgImpl(org.getName(), org.getType(), org.getHref(), description, catalogs, vdcs, + networks, tasksLists, keysList, deviceTags, vAppCatalog, dataCentersList); + } + + @Override + public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException { + Map attributes = cleanseAttributes(attrs); + super.startElement(uri, localName, qName, attrs); + if (qName.equals("Link")) { + if (attributes.containsKey("type")) { + String type = attributes.get("type"); + if (type != null && type.endsWith("dataCentersList+xml")) { + dataCentersList = newReferenceType(attributes); + } else if (type != null && type.endsWith("tagsList+xml")) { + deviceTags = newReferenceType(attributes); + } else if (type != null && type.endsWith("VAppCatalogList+xml")) { + vAppCatalog = newReferenceType(attributes); + } + } + } + } +} diff --git a/providers/trmk-ecloud/src/main/java/org/jclouds/vcloud/terremark/TerremarkECloudAsyncClient.java b/providers/trmk-ecloud/src/main/java/org/jclouds/vcloud/terremark/TerremarkECloudAsyncClient.java index 76ddf1c302..6e1c982718 100644 --- a/providers/trmk-ecloud/src/main/java/org/jclouds/vcloud/terremark/TerremarkECloudAsyncClient.java +++ b/providers/trmk-ecloud/src/main/java/org/jclouds/vcloud/terremark/TerremarkECloudAsyncClient.java @@ -20,6 +20,7 @@ package org.jclouds.vcloud.terremark; import static javax.ws.rs.core.MediaType.APPLICATION_XML; import static org.jclouds.vcloud.VCloudMediaType.NETWORK_XML; +import static org.jclouds.vcloud.VCloudMediaType.ORG_XML; import static org.jclouds.vcloud.terremark.TerremarkECloudMediaType.INTERNETSERVICESLIST_XML; import static org.jclouds.vcloud.terremark.TerremarkECloudMediaType.INTERNETSERVICE_XML; import static org.jclouds.vcloud.terremark.TerremarkECloudMediaType.IPADDRESS_LIST_XML; @@ -38,6 +39,7 @@ import javax.ws.rs.POST; import javax.ws.rs.Path; import javax.ws.rs.Produces; +import org.jclouds.rest.annotations.Delegate; import org.jclouds.rest.annotations.EndpointParam; import org.jclouds.rest.annotations.ExceptionParser; import org.jclouds.rest.annotations.MapBinder; @@ -47,7 +49,12 @@ import org.jclouds.rest.annotations.XMLResponseParser; import org.jclouds.rest.functions.ReturnEmptySetOnNotFoundOr404; import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404; import org.jclouds.rest.functions.ReturnVoidOnNotFoundOr404; +import org.jclouds.terremark.ecloud.domain.TerremarkECloudOrg; +import org.jclouds.terremark.ecloud.features.DataCenterOperationsAsyncClient; +import org.jclouds.terremark.ecloud.features.TagOperationsAsyncClient; +import org.jclouds.terremark.ecloud.xml.TerremarkECloudOrgHandler; import org.jclouds.vcloud.filters.SetVCloudTokenCookie; +import org.jclouds.vcloud.functions.OrgNameToEndpoint; import org.jclouds.vcloud.functions.OrgNameVDCNameResourceEntityNameToEndpoint; import org.jclouds.vcloud.terremark.binders.BindCreateKeyToXmlPayload; import org.jclouds.vcloud.terremark.domain.InternetService; @@ -56,8 +63,9 @@ import org.jclouds.vcloud.terremark.domain.KeyPair; import org.jclouds.vcloud.terremark.domain.Protocol; import org.jclouds.vcloud.terremark.domain.PublicIpAddress; import org.jclouds.vcloud.terremark.domain.TerremarkNetwork; -import org.jclouds.vcloud.terremark.domain.VAppExtendedInfo; +import org.jclouds.vcloud.terremark.domain.TerremarkOrg; import org.jclouds.vcloud.terremark.domain.TerremarkOrgNetwork; +import org.jclouds.vcloud.terremark.domain.VAppExtendedInfo; import org.jclouds.vcloud.terremark.functions.OrgURIToKeysListEndpoint; import org.jclouds.vcloud.terremark.functions.VDCURIToInternetServicesEndpoint; import org.jclouds.vcloud.terremark.functions.VDCURIToPublicIPsEndpoint; @@ -84,7 +92,35 @@ import com.google.common.util.concurrent.ListenableFuture; */ @RequestFilters(SetVCloudTokenCookie.class) public interface TerremarkECloudAsyncClient extends TerremarkVCloudAsyncClient { - + /** + * Provides asynchronous access to Data Center Operations. + * + */ + @Delegate + DataCenterOperationsAsyncClient getDataCenterOperationsClient(); + + /** + * Provides asynchronous access to Tag Operations. + * + */ + @Delegate + TagOperationsAsyncClient getTagOperationsClient(); + + @Override + @GET + @XMLResponseParser(TerremarkECloudOrgHandler.class) + @ExceptionParser(ReturnNullOnNotFoundOr404.class) + @Consumes(ORG_XML) + ListenableFuture getOrg(@EndpointParam URI orgId); + + @Override + @GET + @XMLResponseParser(TerremarkECloudOrgHandler.class) + @ExceptionParser(ReturnNullOnNotFoundOr404.class) + @Consumes(ORG_XML) + ListenableFuture findOrgNamed( + @Nullable @EndpointParam(parser = OrgNameToEndpoint.class) String orgName); + /** * @see TerremarkVCloudExpressClient#getAllInternetServices */ @@ -152,7 +188,7 @@ public interface TerremarkECloudAsyncClient extends TerremarkVCloudAsyncClient { @Nullable @EndpointParam(parser = OrgURIToKeysListEndpoint.class) URI org, String keyName); /** - * @see TerremarkVCloudExpressClient#listKeyPairsInOrgNamed + * @see TerremarkVCloudExpressClient#listKeyPairsInOrg */ @GET @Consumes(KEYSLIST_XML) @@ -262,4 +298,5 @@ public interface TerremarkECloudAsyncClient extends TerremarkVCloudAsyncClient { @XMLResponseParser(VAppExtendedInfoHandler.class) @ExceptionParser(ReturnNullOnNotFoundOr404.class) ListenableFuture getVAppExtendedInfo(@EndpointParam URI href); + } diff --git a/providers/trmk-ecloud/src/main/java/org/jclouds/vcloud/terremark/TerremarkECloudClient.java b/providers/trmk-ecloud/src/main/java/org/jclouds/vcloud/terremark/TerremarkECloudClient.java index cef87694cc..3259c2e327 100644 --- a/providers/trmk-ecloud/src/main/java/org/jclouds/vcloud/terremark/TerremarkECloudClient.java +++ b/providers/trmk-ecloud/src/main/java/org/jclouds/vcloud/terremark/TerremarkECloudClient.java @@ -25,6 +25,10 @@ import java.util.concurrent.TimeUnit; import javax.annotation.Nullable; import org.jclouds.concurrent.Timeout; +import org.jclouds.rest.annotations.Delegate; +import org.jclouds.terremark.ecloud.domain.TerremarkECloudOrg; +import org.jclouds.terremark.ecloud.features.DataCenterOperationsClient; +import org.jclouds.terremark.ecloud.features.TagOperationsClient; import org.jclouds.vcloud.terremark.domain.IpAddress; import org.jclouds.vcloud.terremark.domain.PublicIpAddress; import org.jclouds.vcloud.terremark.domain.TerremarkNetwork; @@ -35,11 +39,32 @@ import org.jclouds.vcloud.terremark.domain.VAppExtendedInfo; * Provides access to VCloud resources via their REST API. *

    * - * @see + * @see * @author Adrian Cole */ @Timeout(duration = 300, timeUnit = TimeUnit.SECONDS) public interface TerremarkECloudClient extends TerremarkVCloudClient { + /** + * Provides synchronous access to Data Center Operations. + * + */ + @Delegate + DataCenterOperationsClient getDataCenterOperationsClient(); + + /** + * Provides synchronous access to Data Center Operations. + * + */ + @Delegate + TagOperationsClient getTagOperationsClient(); + + /** + * {@inheritDoc} + */ + @Override + TerremarkECloudOrg getOrg(URI orgId); /** * Allocate a new public IP @@ -56,14 +81,16 @@ public interface TerremarkECloudClient extends TerremarkVCloudClient { TerremarkOrgNetwork getNetwork(URI network); TerremarkNetwork getTerremarkNetwork(URI network); - + Set getIpAddresses(URI network); /** * Returns extended information for the vApp. - * - * @param vApp The URI at which the vApp information is available. - * @return Extended vApp information like tags, long name, network adapter information. + * + * @param vApp + * The URI at which the vApp information is available. + * @return Extended vApp information like tags, long name, network adapter + * information. */ VAppExtendedInfo getVAppExtendedInfo(URI href); } diff --git a/providers/trmk-ecloud/src/main/java/org/jclouds/vcloud/terremark/TerremarkECloudMediaType.java b/providers/trmk-ecloud/src/main/java/org/jclouds/vcloud/terremark/TerremarkECloudMediaType.java index 95f527b3e3..c1d39db12f 100644 --- a/providers/trmk-ecloud/src/main/java/org/jclouds/vcloud/terremark/TerremarkECloudMediaType.java +++ b/providers/trmk-ecloud/src/main/java/org/jclouds/vcloud/terremark/TerremarkECloudMediaType.java @@ -22,7 +22,7 @@ import javax.ws.rs.core.MediaType; /** * Resource Types used in Terremark eCloud - * + * * @see MediaType */ public interface TerremarkECloudMediaType extends TerremarkVCloudMediaType { @@ -66,6 +66,36 @@ public interface TerremarkECloudMediaType extends TerremarkVCloudMediaType { * "application/vnd.tmrk.ecloud.keysList+xml" */ public final static MediaType KEYSLIST_XML_TYPE = new MediaType("application", "vnd.tmrk.ecloud.keysList+xml"); + /** + * "application/vnd.tmrk.ecloud.tagsList+xml" + */ + public final static String TAGSLISTLIST_XML = "application/vnd.tmrk.ecloud.tagsList+xml"; + + /** + * "application/vnd.tmrk.ecloud.tagsList+xml" + */ + public final static MediaType TAGSLISTLIST_XML_TYPE = new MediaType("application", "vnd.tmrk.ecloud.tagsList+xml"); + /** + * "application/vnd.tmrk.ecloud.VAppCatalogList+xml" + */ + public final static String VAPPCATALOGLIST_XML = "application/vnd.tmrk.ecloud.VAppCatalogList+xml"; + + /** + * "application/vnd.tmrk.ecloud.VAppCatalogList+xml" + */ + public final static MediaType VAPPCATALOGLIST_XML_TYPE = new MediaType("application", + "vnd.tmrk.ecloud.VAppCatalogList+xml"); + + /** + * "application/vnd.tmrk.ecloud.dataCentersList+xml" + */ + public final static String DATACENTERSLIST_XML = "application/vnd.tmrk.ecloud.dataCentersList+xml"; + + /** + * "application/vnd.tmrk.ecloud.dataCentersList+xml" + */ + public final static MediaType DATACENTERSLIST_XML_TYPE = new MediaType("application", + "vnd.tmrk.ecloud.dataCentersList+xml"); /** * "application/vnd.tmrk.ecloud.ipAddressList+xml" @@ -75,7 +105,8 @@ public interface TerremarkECloudMediaType extends TerremarkVCloudMediaType { /** * "application/vnd.tmrk.ecloud.ipAddressList+xml" */ - public final static MediaType IPADDRESSES_LIST_XML_TYPE = new MediaType("application", "vnd.tmrk.ecloud.ipAddressList+xml"); + public final static MediaType IPADDRESSES_LIST_XML_TYPE = new MediaType("application", + "vnd.tmrk.ecloud.ipAddressList+xml"); /** * "application/vnd.tmrk.ecloud.vApp+xml" diff --git a/providers/trmk-ecloud/src/main/java/org/jclouds/vcloud/terremark/compute/functions/TerremarkECloudParseOsFromVAppTemplateName.java b/providers/trmk-ecloud/src/main/java/org/jclouds/vcloud/terremark/compute/functions/TerremarkECloudParseOsFromVAppTemplateName.java index 0d0d0b9af6..efd7cbeb7e 100644 --- a/providers/trmk-ecloud/src/main/java/org/jclouds/vcloud/terremark/compute/functions/TerremarkECloudParseOsFromVAppTemplateName.java +++ b/providers/trmk-ecloud/src/main/java/org/jclouds/vcloud/terremark/compute/functions/TerremarkECloudParseOsFromVAppTemplateName.java @@ -29,7 +29,7 @@ import javax.inject.Inject; import javax.inject.Singleton; import org.jclouds.compute.domain.OperatingSystem; -import org.jclouds.compute.domain.OperatingSystemBuilder; +import org.jclouds.compute.domain.OperatingSystem.Builder; import org.jclouds.compute.domain.OsFamily; import org.jclouds.compute.util.ComputeServiceUtils; import org.jclouds.vcloud.compute.functions.ParseOsFromVAppTemplateName; @@ -50,7 +50,7 @@ public class TerremarkECloudParseOsFromVAppTemplateName extends ParseOsFromVAppT @Override public OperatingSystem apply(String from) { checkNotNull(from, "vapp template name"); - OperatingSystemBuilder builder = new OperatingSystemBuilder(); + Builder builder = new OperatingSystem.Builder(); builder.description(from); if (from.equals("-Windows 2003 Std. R2 SQL 2005 Std. (x64)")) System.out.print(';'); diff --git a/providers/trmk-ecloud/src/main/java/org/jclouds/vcloud/terremark/config/TerremarkECloudRestClientModule.java b/providers/trmk-ecloud/src/main/java/org/jclouds/vcloud/terremark/config/TerremarkECloudRestClientModule.java index 257a280e1d..3244de1357 100644 --- a/providers/trmk-ecloud/src/main/java/org/jclouds/vcloud/terremark/config/TerremarkECloudRestClientModule.java +++ b/providers/trmk-ecloud/src/main/java/org/jclouds/vcloud/terremark/config/TerremarkECloudRestClientModule.java @@ -29,6 +29,10 @@ import javax.inject.Singleton; import org.jclouds.http.RequiresHttp; import org.jclouds.rest.ConfiguresRestClient; import org.jclouds.rest.ResourceNotFoundException; +import org.jclouds.terremark.ecloud.features.DataCenterOperationsAsyncClient; +import org.jclouds.terremark.ecloud.features.DataCenterOperationsClient; +import org.jclouds.terremark.ecloud.features.TagOperationsAsyncClient; +import org.jclouds.terremark.ecloud.features.TagOperationsClient; import org.jclouds.vcloud.VCloudExpressAsyncClient; import org.jclouds.vcloud.VCloudExpressClient; import org.jclouds.vcloud.domain.ReferenceType; @@ -40,6 +44,7 @@ import org.jclouds.vcloud.terremark.domain.TerremarkNetwork; import org.jclouds.vcloud.terremark.domain.TerremarkOrgNetwork; import com.google.common.base.Predicate; +import com.google.common.collect.ImmutableMap; import com.google.common.collect.Iterables; import com.google.inject.Injector; import com.google.inject.Provides; @@ -54,8 +59,13 @@ import com.google.inject.Provides; public class TerremarkECloudRestClientModule extends TerremarkRestClientModule { + public static final Map, Class> DELEGATE_MAP = ImmutableMap., Class> builder()// + .put(DataCenterOperationsClient.class, DataCenterOperationsAsyncClient.class)// + .put(TagOperationsClient.class, TagOperationsAsyncClient.class)// + .build(); + public TerremarkECloudRestClientModule() { - super(TerremarkECloudClient.class, TerremarkECloudAsyncClient.class); + super(TerremarkECloudClient.class, TerremarkECloudAsyncClient.class, DELEGATE_MAP); } @Provides diff --git a/providers/trmk-ecloud/src/test/java/org/jclouds/terremark/ecloud/BaseTerremarkECloudAsyncClientTest.java b/providers/trmk-ecloud/src/test/java/org/jclouds/terremark/ecloud/BaseTerremarkECloudAsyncClientTest.java new file mode 100644 index 0000000000..097fa449c3 --- /dev/null +++ b/providers/trmk-ecloud/src/test/java/org/jclouds/terremark/ecloud/BaseTerremarkECloudAsyncClientTest.java @@ -0,0 +1,243 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.jclouds.terremark.ecloud; + +import static org.jclouds.Constants.PROPERTY_API_VERSION; +import static org.jclouds.Constants.PROPERTY_IDENTITY; +import static org.testng.Assert.assertEquals; + +import java.net.URI; +import java.util.Map; +import java.util.Properties; + +import javax.inject.Inject; +import javax.inject.Named; +import javax.inject.Singleton; + +import org.jclouds.http.HttpRequest; +import org.jclouds.http.RequiresHttp; +import org.jclouds.rest.ConfiguresRestClient; +import org.jclouds.rest.RestClientTest; +import org.jclouds.rest.RestContextFactory; +import org.jclouds.rest.RestContextSpec; +import org.jclouds.terremark.ecloud.domain.internal.TerremarkECloudOrgImpl; +import org.jclouds.vcloud.CommonVCloudClient; +import org.jclouds.vcloud.VCloudExpressAsyncClientTest.VCloudRestClientModuleExtension.TestOrgCatalogItemSupplier; +import org.jclouds.vcloud.VCloudExpressAsyncClientTest.VCloudRestClientModuleExtension.TestOrgCatalogSupplier; +import org.jclouds.vcloud.VCloudVersionsAsyncClient; +import org.jclouds.vcloud.config.CommonVCloudRestClientModule.OrgVDCSupplier; +import org.jclouds.vcloud.domain.AllocationModel; +import org.jclouds.vcloud.domain.Capacity; +import org.jclouds.vcloud.domain.Org; +import org.jclouds.vcloud.domain.ReferenceType; +import org.jclouds.vcloud.domain.Task; +import org.jclouds.vcloud.domain.VCloudSession; +import org.jclouds.vcloud.domain.VDCStatus; +import org.jclouds.vcloud.domain.internal.ReferenceTypeImpl; +import org.jclouds.vcloud.filters.SetVCloudTokenCookie; +import org.jclouds.vcloud.terremark.TerremarkECloudMediaType; +import org.jclouds.vcloud.terremark.TerremarkVCloudMediaType; +import org.jclouds.vcloud.terremark.config.TerremarkECloudRestClientModule; +import org.jclouds.vcloud.terremark.domain.internal.TerremarkVDCImpl; + +import com.google.common.base.Function; +import com.google.common.base.Supplier; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Maps; +import com.google.inject.Injector; +import com.google.inject.Module; + +/** + * @author Adrian Cole + */ +public abstract class BaseTerremarkECloudAsyncClientTest extends RestClientTest { + + @RequiresHttp + @ConfiguresRestClient + protected static class TerremarkVCloudRestClientModuleExtension extends TerremarkECloudRestClientModule { + @Override + protected URI provideAuthenticationURI(VCloudVersionsAsyncClient versionService, + @Named(PROPERTY_API_VERSION) String version) { + return URI.create("https://vcloud/login"); + } + + @Override + protected void configure() { + super.configure(); + bind(OrgNameToKeysListSupplier.class).to(TestOrgNameToKeysListSupplier.class); + bind(OrgMapSupplier.class).to(TestTerremarkOrgMapSupplier.class); + bind(OrgCatalogSupplier.class).to(TestOrgCatalogSupplier.class); + bind(OrgCatalogItemSupplier.class).to(TestOrgCatalogItemSupplier.class); + bind(OrgVDCSupplier.class).to(TestTerremarkOrgVDCSupplier.class); + } + + @Singleton + public static class TestOrgNameToKeysListSupplier extends OrgNameToKeysListSupplier { + @Inject + protected TestOrgNameToKeysListSupplier(Supplier sessionSupplier) { + super(sessionSupplier, null); + } + + @Override + public Map get() { + return Maps.transformValues(sessionSupplier.get().getOrgs(), new Function() { + + @Override + public ReferenceType apply(ReferenceType from) { + return new ReferenceTypeImpl(from.getName(), TerremarkECloudMediaType.KEYSLIST_XML, URI.create(from + .getHref().toASCIIString() + "/keysList")); + } + }); + } + } + + @Singleton + public static class TestTerremarkOrgMapSupplier extends OrgMapSupplier { + @Inject + protected TestTerremarkOrgMapSupplier() { + super(null, null); + } + + @Override + public Map get() { + return ImmutableMap. of( + "org", + new TerremarkECloudOrgImpl("org", null, + URI.create("https://vcloud.safesecureweb.com/api/v0.8/org/1"), null, ImmutableMap + . of( + "catalog", + new ReferenceTypeImpl("catalog", TerremarkECloudMediaType.CATALOG_XML, URI + .create("https://vcloud.safesecureweb.com/api/v0.8/catalog/1"))), + ImmutableMap. of( + "vdc", + new ReferenceTypeImpl("vdc", TerremarkECloudMediaType.VDC_XML, URI + .create("https://vcloud.safesecureweb.com/api/v0.8/vdc/1"))), ImmutableMap + . of(), ImmutableMap. of( + "tasksList", + new ReferenceTypeImpl("tasksList", TerremarkECloudMediaType.TASKSLIST_XML, URI + .create("https://vcloud.safesecureweb.com/api/v0.8/tasksList/1"))), + new ReferenceTypeImpl("keysList", TerremarkECloudMediaType.KEYSLIST_XML, URI + .create("https://vcloud.safesecureweb.com/api/v0.8/keysList/1")), new ReferenceTypeImpl( + "deviceTags", TerremarkECloudMediaType.TAGSLISTLIST_XML, URI + .create("https://vcloud.safesecureweb.com/api/v0.8/deviceTags/1")), + new ReferenceTypeImpl("vappCatalog", TerremarkECloudMediaType.VAPPCATALOGLIST_XML, URI + .create("https://vcloud.safesecureweb.com/api/v0.8/vappCatalog/1")), + new ReferenceTypeImpl("dataCentersList", TerremarkECloudMediaType.DATACENTERSLIST_XML, URI + .create("https://vcloud.safesecureweb.com/api/v0.8/datacentersList/1")))); + } + } + + @Override + protected URI provideOrg(@org.jclouds.vcloud.endpoints.Org Iterable orgs) { + return URI.create("https://org"); + } + + @Override + protected String provideOrgName(@org.jclouds.vcloud.endpoints.Org Iterable orgs) { + return "org"; + } + + @Override + protected URI provideCatalog(Org org, @Named(PROPERTY_IDENTITY) String user, WriteableCatalog write) { + return URI.create("https://catalog"); + } + + @Override + protected Org provideOrg(CommonVCloudClient discovery) { + return null; + } + + @Override + protected Iterable provideOrgs(Supplier cache, String user) { + return null; + } + + @Override + protected URI provideDefaultTasksList(Org org) { + return URI.create("https://taskslist"); + } + + @Override + protected URI provideDefaultVDC(Org org, @org.jclouds.vcloud.endpoints.VDC String defaultVDC) { + return URI.create("https://vdc/1"); + } + + @Override + protected String provideDefaultVDCName( + @org.jclouds.vcloud.endpoints.VDC Supplier> vDCtoOrgSupplier) { + return "vdc"; + } + + @Override + protected URI provideDefaultNetwork(URI vdc, Injector injector) { + return URI.create("https://vcloud.safesecureweb.com/network/1990"); + } + } + + @Override + protected void checkFilters(HttpRequest request) { + assertEquals(request.getFilters().size(), 1); + assertEquals(request.getFilters().get(0).getClass(), SetVCloudTokenCookie.class); + } + + @Override + protected Module createModule() { + return new TerremarkVCloudRestClientModuleExtension(); + } + + @Override + public RestContextSpec createContextSpec() { + return new RestContextFactory().createContextSpec("trmk-ecloud", "identity", "credential", new Properties()); + } + + @Singleton + public static class TestTerremarkOrgVDCSupplier extends OrgVDCSupplier { + @Inject + protected TestTerremarkOrgVDCSupplier() { + super(null, null); + } + + @Override + public Map> get() { + return ImmutableMap.> of("org", + + ImmutableMap. of( + "vdc", + new TerremarkVDCImpl("vdc", null, URI.create("https://vcloud.safesecureweb.com/api/v0.8/vdc/1"), + VDCStatus.READY, null, "description", ImmutableSet. of(), AllocationModel.UNRECOGNIZED, + new Capacity("MB", 0, 0, 0, 0), new Capacity("MB", 0, 0, 0, 0), new Capacity("MB", 0, 0, 0, 0), + ImmutableMap. of( + "vapp", + new ReferenceTypeImpl("vapp", "application/vnd.vmware.vcloud.vApp+xml", URI + .create("https://vcloud.safesecureweb.com/api/v0.8/vApp/188849-1")), + "network", + new ReferenceTypeImpl("network", "application/vnd.vmware.vcloud.vAppTemplate+xml", URI + .create("https://vcloud.safesecureweb.com/api/v0.8/vdcItem/2"))), ImmutableMap + . of(), 0, 0, 0, false, new ReferenceTypeImpl("catalog", + TerremarkVCloudMediaType.CATALOG_XML, URI + .create("https://vcloud.safesecureweb.com/api/v0.8/catalog/1")), + new ReferenceTypeImpl("publicIps", TerremarkVCloudMediaType.PUBLICIPSLIST_XML, URI + .create("https://vcloud.safesecureweb.com/api/v0.8/publicIps/1")), new ReferenceTypeImpl( + "internetServices", TerremarkVCloudMediaType.INTERNETSERVICESLIST_XML, URI + .create("https://vcloud.safesecureweb.com/api/v0.8/internetServices/1"))))); + } + } + +} \ No newline at end of file diff --git a/providers/trmk-ecloud/src/test/java/org/jclouds/terremark/ecloud/BaseTerremarkECloudClientLiveTest.java b/providers/trmk-ecloud/src/test/java/org/jclouds/terremark/ecloud/BaseTerremarkECloudClientLiveTest.java new file mode 100644 index 0000000000..7da1548044 --- /dev/null +++ b/providers/trmk-ecloud/src/test/java/org/jclouds/terremark/ecloud/BaseTerremarkECloudClientLiveTest.java @@ -0,0 +1,31 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.jclouds.terremark.ecloud; + +import org.jclouds.vcloud.terremark.BaseTerremarkClientLiveTest; +import org.jclouds.vcloud.terremark.TerremarkECloudClient; +import org.testng.annotations.Test; + +/** + * @author Adrian Cole + */ +@Test(groups = "live", enabled = true, singleThreaded = true) +public class BaseTerremarkECloudClientLiveTest extends BaseTerremarkClientLiveTest { + +} \ No newline at end of file diff --git a/providers/trmk-ecloud/src/test/java/org/jclouds/terremark/ecloud/features/DataCenterOperationsAsyncClientTest.java b/providers/trmk-ecloud/src/test/java/org/jclouds/terremark/ecloud/features/DataCenterOperationsAsyncClientTest.java new file mode 100644 index 0000000000..bbfb1dc23a --- /dev/null +++ b/providers/trmk-ecloud/src/test/java/org/jclouds/terremark/ecloud/features/DataCenterOperationsAsyncClientTest.java @@ -0,0 +1,70 @@ +package org.jclouds.terremark.ecloud.features; + +import java.io.IOException; +import java.lang.reflect.Method; +import java.net.URI; + +import org.jclouds.http.HttpRequest; +import org.jclouds.http.functions.ParseSax; +import org.jclouds.rest.functions.ReturnEmptySetOnNotFoundOr404; +import org.jclouds.rest.internal.RestAnnotationProcessor; +import org.jclouds.terremark.ecloud.BaseTerremarkECloudAsyncClientTest; +import org.jclouds.terremark.ecloud.features.DataCenterOperationsAsyncClient; +import org.jclouds.vcloud.terremark.xml.DataCentersHandler; +import org.testng.annotations.Test; + +import com.google.inject.TypeLiteral; + +/** + * Tests behavior of {@code DataCenterOperationsAsyncClient} + * + * @author Adrian Cole + */ +// NOTE:without testName, this will not call @Before* and fail w/NPE during +// surefire +@Test(groups = "unit", testName = "DataCenterOperationsAsyncClientTest") +public class DataCenterOperationsAsyncClientTest extends + BaseTerremarkECloudAsyncClientTest { + + @Override + protected TypeLiteral> createTypeLiteral() { + return new TypeLiteral>() { + }; + } + + public void testlistDataCenters() throws SecurityException, NoSuchMethodException, IOException { + Method method = DataCenterOperationsAsyncClient.class.getMethod("listDataCenters", URI.class); + HttpRequest request = processor + .createRequest( + method, + URI.create("https://services.enterprisecloud.terremark.com/api/v0.8b-ext2.8/extensions/org/1910324/dataCenters")); + + assertRequestLineEquals(request, + "GET https://services.enterprisecloud.terremark.com/api/v0.8b-ext2.8/extensions/org/1910324/dataCenters HTTP/1.1"); + assertNonPayloadHeadersEqual(request, "Accept: application/vnd.tmrk.ecloud.dataCentersList+xml\n"); + assertPayloadEquals(request, null, null, false); + + assertResponseParserClassEquals(method, request, ParseSax.class); + assertSaxResponseParserClassEquals(method, DataCentersHandler.class); + assertExceptionParserClassEquals(method, ReturnEmptySetOnNotFoundOr404.class); + + checkFilters(request); + } + + public void testlistDataCentersInOrg() throws SecurityException, NoSuchMethodException, IOException { + Method method = DataCenterOperationsAsyncClient.class.getMethod("listDataCentersInOrg", URI.class); + HttpRequest request = processor.createRequest(method, + URI.create("https://vcloud.safesecureweb.com/api/v0.8/org/1")); + + assertRequestLineEquals(request, "GET https://vcloud.safesecureweb.com/api/v0.8/datacentersList/1 HTTP/1.1"); + assertNonPayloadHeadersEqual(request, "Accept: application/vnd.tmrk.ecloud.dataCentersList+xml\n"); + assertPayloadEquals(request, null, null, false); + + assertResponseParserClassEquals(method, request, ParseSax.class); + assertSaxResponseParserClassEquals(method, DataCentersHandler.class); + assertExceptionParserClassEquals(method, ReturnEmptySetOnNotFoundOr404.class); + + checkFilters(request); + } + +} diff --git a/providers/trmk-ecloud/src/test/java/org/jclouds/terremark/ecloud/features/DataCenterOperationsClientLiveTest.java b/providers/trmk-ecloud/src/test/java/org/jclouds/terremark/ecloud/features/DataCenterOperationsClientLiveTest.java new file mode 100644 index 0000000000..68a90e8f5f --- /dev/null +++ b/providers/trmk-ecloud/src/test/java/org/jclouds/terremark/ecloud/features/DataCenterOperationsClientLiveTest.java @@ -0,0 +1,45 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.jclouds.terremark.ecloud.features; + +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertNotNull; + +import org.jclouds.terremark.ecloud.BaseTerremarkECloudClientLiveTest; +import org.jclouds.terremark.ecloud.domain.TerremarkECloudOrg; +import org.jclouds.vcloud.domain.ReferenceType; +import org.testng.annotations.Test; + +/** + * @author Adrian Cole + */ +@Test(groups = "live", enabled = true, singleThreaded = true, testName = "DataCenterOperationsClientLiveTest") +public class DataCenterOperationsClientLiveTest extends BaseTerremarkECloudClientLiveTest { + @Test + public void testListDataCentersInOrg() throws Exception { + for (ReferenceType response : getApi().listOrgs()) { + TerremarkECloudOrg org = getApi().getOrg(response.getHref()); + assertNotNull(response); + assertNotNull(response.getName()); + assertNotNull(response.getHref()); + assertEquals(getApi().getDataCenterOperationsClient().listDataCentersInOrg(org.getHref()), getApi() + .getDataCenterOperationsClient().listDataCenters(org.getDataCenters().getHref())); + } + } +} \ No newline at end of file diff --git a/providers/trmk-ecloud/src/test/java/org/jclouds/terremark/ecloud/features/TagOperationsAsyncClientTest.java b/providers/trmk-ecloud/src/test/java/org/jclouds/terremark/ecloud/features/TagOperationsAsyncClientTest.java new file mode 100644 index 0000000000..285de75200 --- /dev/null +++ b/providers/trmk-ecloud/src/test/java/org/jclouds/terremark/ecloud/features/TagOperationsAsyncClientTest.java @@ -0,0 +1,68 @@ +package org.jclouds.terremark.ecloud.features; + +import java.io.IOException; +import java.lang.reflect.Method; +import java.net.URI; + +import org.jclouds.http.HttpRequest; +import org.jclouds.http.functions.ParseSax; +import org.jclouds.rest.functions.ReturnEmptyMapOnNotFoundOr404; +import org.jclouds.rest.internal.RestAnnotationProcessor; +import org.jclouds.terremark.ecloud.BaseTerremarkECloudAsyncClientTest; +import org.jclouds.terremark.ecloud.xml.TagNameToUsageCountHandler; +import org.testng.annotations.Test; + +import com.google.inject.TypeLiteral; + +/** + * Tests behavior of {@code TagOperationsAsyncClient} + * + * @author Adrian Cole + */ +// NOTE:without testName, this will not call @Before* and fail w/NPE during +// surefire +@Test(groups = "unit", testName = "TagOperationsAsyncClientTest") +public class TagOperationsAsyncClientTest extends BaseTerremarkECloudAsyncClientTest { + + @Override + protected TypeLiteral> createTypeLiteral() { + return new TypeLiteral>() { + }; + } + + public void testgetTagNameToUsageCount() throws SecurityException, NoSuchMethodException, IOException { + Method method = TagOperationsAsyncClient.class.getMethod("getTagNameToUsageCount", URI.class); + HttpRequest request = processor + .createRequest( + method, + URI.create("https://services.enterprisecloud.terremark.com/api/v0.8b-ext2.8/extensions/org/1910324/deviceTags")); + + assertRequestLineEquals(request, + "GET https://services.enterprisecloud.terremark.com/api/v0.8b-ext2.8/extensions/org/1910324/deviceTags HTTP/1.1"); + assertNonPayloadHeadersEqual(request, "Accept: application/vnd.tmrk.ecloud.tagsList+xml\n"); + assertPayloadEquals(request, null, null, false); + + assertResponseParserClassEquals(method, request, ParseSax.class); + assertSaxResponseParserClassEquals(method, TagNameToUsageCountHandler.class); + assertExceptionParserClassEquals(method, ReturnEmptyMapOnNotFoundOr404.class); + + checkFilters(request); + } + + public void testgetTagNameToUsageCountInOrg() throws SecurityException, NoSuchMethodException, IOException { + Method method = TagOperationsAsyncClient.class.getMethod("getTagNameToUsageCountInOrg", URI.class); + HttpRequest request = processor.createRequest(method, + URI.create("https://vcloud.safesecureweb.com/api/v0.8/org/1")); + + assertRequestLineEquals(request, "GET https://vcloud.safesecureweb.com/api/v0.8/deviceTags/1 HTTP/1.1"); + assertNonPayloadHeadersEqual(request, "Accept: application/vnd.tmrk.ecloud.tagsList+xml\n"); + assertPayloadEquals(request, null, null, false); + + assertResponseParserClassEquals(method, request, ParseSax.class); + assertSaxResponseParserClassEquals(method, TagNameToUsageCountHandler.class); + assertExceptionParserClassEquals(method, ReturnEmptyMapOnNotFoundOr404.class); + + checkFilters(request); + } + +} diff --git a/providers/trmk-ecloud/src/test/java/org/jclouds/terremark/ecloud/features/TagOperationsClientLiveTest.java b/providers/trmk-ecloud/src/test/java/org/jclouds/terremark/ecloud/features/TagOperationsClientLiveTest.java new file mode 100644 index 0000000000..b8f537cd49 --- /dev/null +++ b/providers/trmk-ecloud/src/test/java/org/jclouds/terremark/ecloud/features/TagOperationsClientLiveTest.java @@ -0,0 +1,45 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.jclouds.terremark.ecloud.features; + +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertNotNull; + +import org.jclouds.terremark.ecloud.BaseTerremarkECloudClientLiveTest; +import org.jclouds.terremark.ecloud.domain.TerremarkECloudOrg; +import org.jclouds.vcloud.domain.ReferenceType; +import org.testng.annotations.Test; + +/** + * @author Adrian Cole + */ +@Test(groups = "live", enabled = true, singleThreaded = true, testName = "TagOperationsClientLiveTest") +public class TagOperationsClientLiveTest extends BaseTerremarkECloudClientLiveTest { + @Test + public void testListTagsInOrg() throws Exception { + for (ReferenceType response : getApi().listOrgs()) { + TerremarkECloudOrg org = getApi().getOrg(response.getHref()); + assertNotNull(response); + assertNotNull(response.getName()); + assertNotNull(response.getHref()); + assertEquals(getApi().getTagOperationsClient().getTagNameToUsageCountInOrg(org.getHref()), getApi() + .getTagOperationsClient().getTagNameToUsageCount(org.getTags().getHref())); + } + } +} \ No newline at end of file diff --git a/providers/trmk-ecloud/src/test/java/org/jclouds/terremark/ecloud/xml/TagNameToUsageCountHandlerTest.java b/providers/trmk-ecloud/src/test/java/org/jclouds/terremark/ecloud/xml/TagNameToUsageCountHandlerTest.java new file mode 100644 index 0000000000..0e6e946e07 --- /dev/null +++ b/providers/trmk-ecloud/src/test/java/org/jclouds/terremark/ecloud/xml/TagNameToUsageCountHandlerTest.java @@ -0,0 +1,73 @@ +package org.jclouds.terremark.ecloud.xml; + +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ + +import static com.google.common.base.Preconditions.checkNotNull; +import static org.testng.Assert.assertEquals; + +import java.io.InputStream; +import java.util.Map; +import java.util.Properties; + +import org.jclouds.http.functions.BaseHandlerTest; +import org.jclouds.http.functions.ParseSax; +import org.jclouds.http.functions.config.SaxParserModule; +import org.jclouds.vcloud.terremark.TerremarkVCloudPropertiesBuilder; +import org.testng.annotations.BeforeTest; +import org.testng.annotations.Test; + +import com.google.common.collect.ImmutableMap; +import com.google.inject.Guice; +import com.google.inject.name.Names; + +/** + * Tests behavior of {@code TagNameToUsageCountHandler} + * + * @author Adrian Cole + */ +// NOTE:without testName, this will not call @Before* and fail w/NPE during +// surefire +@Test(groups = "unit", testName = "TagNameToUsageCountHandlerTest") +public class TagNameToUsageCountHandlerTest extends BaseHandlerTest { + @Override + @BeforeTest + protected void setUpInjector() { + injector = Guice.createInjector(new SaxParserModule() { + @Override + public void configure() { + super.configure(); + Properties props = new Properties(); + Names.bindProperties(binder(), + checkNotNull(new TerremarkVCloudPropertiesBuilder(props).build(), "properties")); + } + }); + factory = injector.getInstance(ParseSax.Factory.class); + assert factory != null; + } + + public void testApplyInputStream() { + + InputStream is = getClass().getResourceAsStream("/deviceTags.xml"); + + Map result = factory.create(injector.getInstance(TagNameToUsageCountHandler.class)).parse(is); + assertEquals(result, ImmutableMap. of("Tag1", 1, "Tag2", 5, "Tag3", 12)); + + } +} diff --git a/providers/trmk-ecloud/src/test/java/org/jclouds/terremark/ecloud/xml/TerremarkECloudOrgHandlerTest.java b/providers/trmk-ecloud/src/test/java/org/jclouds/terremark/ecloud/xml/TerremarkECloudOrgHandlerTest.java new file mode 100644 index 0000000000..45377d348a --- /dev/null +++ b/providers/trmk-ecloud/src/test/java/org/jclouds/terremark/ecloud/xml/TerremarkECloudOrgHandlerTest.java @@ -0,0 +1,131 @@ +package org.jclouds.terremark.ecloud.xml; + +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ + +import static com.google.common.base.Preconditions.checkNotNull; +import static org.testng.Assert.assertEquals; + +import java.io.InputStream; +import java.net.URI; +import java.util.Properties; + +import org.jclouds.http.functions.BaseHandlerTest; +import org.jclouds.http.functions.ParseSax; +import org.jclouds.http.functions.config.SaxParserModule; +import org.jclouds.terremark.ecloud.domain.TerremarkECloudOrg; +import org.jclouds.vcloud.VCloudExpressMediaType; +import org.jclouds.vcloud.domain.internal.ReferenceTypeImpl; +import org.jclouds.vcloud.terremark.TerremarkVCloudPropertiesBuilder; +import org.testng.annotations.BeforeTest; +import org.testng.annotations.Test; + +import com.google.common.collect.ImmutableMap; +import com.google.inject.Guice; +import com.google.inject.name.Names; + +/** + * Tests behavior of {@code TerremarkECloudOrgHandler} + * + * @author Adrian Cole + */ +// NOTE:without testName, this will not call @Before* and fail w/NPE during +// surefire +@Test(groups = "unit", testName = "TerremarkECloudOrgHandlerTest") +public class TerremarkECloudOrgHandlerTest extends BaseHandlerTest { + @Override + @BeforeTest + protected void setUpInjector() { + injector = Guice.createInjector(new SaxParserModule() { + @Override + public void configure() { + super.configure(); + Properties props = new Properties(); + Names.bindProperties(binder(), + checkNotNull(new TerremarkVCloudPropertiesBuilder(props).build(), "properties")); + } + }); + factory = injector.getInstance(ParseSax.Factory.class); + assert factory != null; + } + + public void testApplyInputStream() { + + InputStream is = getClass().getResourceAsStream("/org-ecloud.xml"); + + TerremarkECloudOrg result = (TerremarkECloudOrg) factory.create( + injector.getInstance(TerremarkECloudOrgHandler.class)).parse(is); + assertEquals(result.getName(), "Cloud Conscious, LLC"); + assertEquals(result.getHref(), + URI.create("https://services.enterprisecloud.terremark.com/api/v0.8b-ext2.8/org/1910324")); + + assertEquals(result.getVDCs(), ImmutableMap.of( + "Cloud Conscious LLC - MIA", + new ReferenceTypeImpl("Cloud Conscious LLC - MIA", VCloudExpressMediaType.VDC_XML, URI + .create("https://services.enterprisecloud.terremark.com/api/v0.8b-ext2.8/vdc/1155")), + "Cloud Conscious LLC - AMA", + new ReferenceTypeImpl("Cloud Conscious LLC - AMA", VCloudExpressMediaType.VDC_XML, URI + .create("https://services.enterprisecloud.terremark.com/api/v0.8b-ext2.8/vdc/1169")))); + + assertEquals(result.getCatalogs(), ImmutableMap.of( + "Cloud Conscious LLC - MIA Catalog", + new ReferenceTypeImpl("Cloud Conscious LLC - MIA Catalog", VCloudExpressMediaType.CATALOG_XML, URI + .create("https://services.enterprisecloud.terremark.com/api/v0.8b-ext2.8/vdc/1155/catalog")), + "Cloud Conscious LLC - AMA Catalog", + new ReferenceTypeImpl("Cloud Conscious LLC - AMA Catalog", VCloudExpressMediaType.CATALOG_XML, URI + .create("https://services.enterprisecloud.terremark.com/api/v0.8b-ext2.8/vdc/1169/catalog")))); + + assertEquals(result.getTasksLists(), ImmutableMap.of( + "Cloud Conscious LLC - MIA Tasks List", + new ReferenceTypeImpl("Cloud Conscious LLC - MIA Tasks List", VCloudExpressMediaType.TASKSLIST_XML, URI + .create("https://services.enterprisecloud.terremark.com/api/v0.8b-ext2.8/vdc/1155/tasksList")), + "Cloud Conscious LLC - AMA Tasks List", + new ReferenceTypeImpl("Cloud Conscious LLC - AMA Tasks List", VCloudExpressMediaType.TASKSLIST_XML, URI + .create("https://services.enterprisecloud.terremark.com/api/v0.8b-ext2.8/vdc/1169/tasksList")))); + + assertEquals( + result.getKeys(), + new ReferenceTypeImpl( + "Keys", + "application/vnd.tmrk.ecloud.keysList+xml", + URI.create("https://services.enterprisecloud.terremark.com/api/v0.8b-ext2.8/extensions/org/1910324/keys"))); + + assertEquals( + result.getTags(), + new ReferenceTypeImpl( + "Device Tags", + "application/vnd.tmrk.ecloud.tagsList+xml", + URI.create("https://services.enterprisecloud.terremark.com/api/v0.8b-ext2.8/extensions/org/1910324/deviceTags"))); + + assertEquals( + result.getVAppCatalog(), + new ReferenceTypeImpl( + "VApp Catalog", + "application/vnd.tmrk.ecloud.VAppCatalogList+xml", + URI.create("https://services.enterprisecloud.terremark.com/api/v0.8b-ext2.8/extensions/org/1910324/vappCatalog"))); + + assertEquals( + result.getDataCenters(), + new ReferenceTypeImpl( + "DataCenters", + "application/vnd.tmrk.ecloud.dataCentersList+xml", + URI.create("https://services.enterprisecloud.terremark.com/api/v0.8b-ext2.8/extensions/org/1910324/dataCenters"))); + + } +} diff --git a/providers/trmk-ecloud/src/test/java/org/jclouds/vcloud/terremark/TerremarkECloudAsyncClientTest.java b/providers/trmk-ecloud/src/test/java/org/jclouds/vcloud/terremark/TerremarkECloudAsyncClientTest.java index 808eb5acf8..2bd57577f1 100644 --- a/providers/trmk-ecloud/src/test/java/org/jclouds/vcloud/terremark/TerremarkECloudAsyncClientTest.java +++ b/providers/trmk-ecloud/src/test/java/org/jclouds/vcloud/terremark/TerremarkECloudAsyncClientTest.java @@ -18,56 +18,27 @@ */ package org.jclouds.vcloud.terremark; -import static org.jclouds.Constants.PROPERTY_API_VERSION; -import static org.jclouds.Constants.PROPERTY_IDENTITY; import static org.jclouds.vcloud.terremark.options.AddInternetServiceOptions.Builder.disabled; -import static org.testng.Assert.assertEquals; import java.io.IOException; import java.lang.reflect.Method; import java.net.URI; -import java.util.Map; -import java.util.Properties; -import javax.inject.Inject; -import javax.inject.Named; -import javax.inject.Singleton; import org.jclouds.http.HttpRequest; -import org.jclouds.http.RequiresHttp; import org.jclouds.http.functions.ParseSax; import org.jclouds.http.functions.ReleasePayloadAndReturn; -import org.jclouds.rest.ConfiguresRestClient; import org.jclouds.rest.ResourceNotFoundException; -import org.jclouds.rest.RestClientTest; -import org.jclouds.rest.RestContextFactory; -import org.jclouds.rest.RestContextSpec; import org.jclouds.rest.functions.ReturnEmptySetOnNotFoundOr404; import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404; import org.jclouds.rest.functions.ReturnVoidOnNotFoundOr404; import org.jclouds.rest.internal.RestAnnotationProcessor; +import org.jclouds.terremark.ecloud.BaseTerremarkECloudAsyncClientTest; import org.jclouds.util.Strings2; -import org.jclouds.vcloud.CommonVCloudClient; -import org.jclouds.vcloud.VCloudVersionsAsyncClient; -import org.jclouds.vcloud.VCloudExpressAsyncClientTest.VCloudRestClientModuleExtension.TestOrgCatalogItemSupplier; -import org.jclouds.vcloud.VCloudExpressAsyncClientTest.VCloudRestClientModuleExtension.TestOrgCatalogSupplier; -import org.jclouds.vcloud.config.CommonVCloudRestClientModule.OrgVDCSupplier; -import org.jclouds.vcloud.domain.AllocationModel; -import org.jclouds.vcloud.domain.Capacity; -import org.jclouds.vcloud.domain.Org; -import org.jclouds.vcloud.domain.ReferenceType; -import org.jclouds.vcloud.domain.Task; -import org.jclouds.vcloud.domain.VCloudSession; -import org.jclouds.vcloud.domain.VDCStatus; -import org.jclouds.vcloud.domain.internal.ReferenceTypeImpl; import org.jclouds.vcloud.domain.network.NetworkConfig; -import org.jclouds.vcloud.filters.SetVCloudTokenCookie; import org.jclouds.vcloud.functions.ParseTaskFromLocationHeader; import org.jclouds.vcloud.options.InstantiateVAppTemplateOptions; -import org.jclouds.vcloud.terremark.config.TerremarkECloudRestClientModule; import org.jclouds.vcloud.terremark.domain.Protocol; -import org.jclouds.vcloud.terremark.domain.internal.TerremarkOrgImpl; -import org.jclouds.vcloud.terremark.domain.internal.TerremarkVDCImpl; import org.jclouds.vcloud.terremark.options.AddInternetServiceOptions; import org.jclouds.vcloud.terremark.options.AddNodeOptions; import org.jclouds.vcloud.terremark.options.TerremarkInstantiateVAppTemplateOptions; @@ -87,23 +58,24 @@ import org.jclouds.vcloud.xml.VCloudExpressCatalogHandler; import org.jclouds.vcloud.xml.VCloudExpressVAppHandler; import org.testng.annotations.Test; -import com.google.common.base.Function; -import com.google.common.base.Supplier; -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Maps; -import com.google.inject.Injector; -import com.google.inject.Module; import com.google.inject.TypeLiteral; + /** * Tests behavior of {@code TerremarkECloudAsyncClient} * * @author Adrian Cole */ // NOTE:without testName, this will not call @Before* and fail w/NPE during surefire -@Test(groups = "unit", sequential = true, testName = "TerremarkECloudAsyncClientTest") -public class TerremarkECloudAsyncClientTest extends RestClientTest { +@Test(groups = "unit", singleThreaded = true, testName = "TerremarkECloudAsyncClientTest") +public class TerremarkECloudAsyncClientTest extends BaseTerremarkECloudAsyncClientTest { + + @Override + protected TypeLiteral> createTypeLiteral() { + return new TypeLiteral>() { + }; + } + public void testNetwork() throws SecurityException, NoSuchMethodException, IOException { Method method = TerremarkECloudAsyncClient.class.getMethod("getNetwork", URI.class); HttpRequest request = processor.createRequest(method, @@ -559,173 +531,4 @@ public class TerremarkECloudAsyncClientTest extends RestClientTest> createTypeLiteral() { - return new TypeLiteral>() { - }; - } - - @Override - protected Module createModule() { - return new TerremarkVCloudRestClientModuleExtension(); - } - - @Override - public RestContextSpec createContextSpec() { - return new RestContextFactory().createContextSpec("trmk-ecloud", "identity", "credential", new Properties()); - } - - @RequiresHttp - @ConfiguresRestClient - protected static class TerremarkVCloudRestClientModuleExtension extends TerremarkECloudRestClientModule { - @Override - protected URI provideAuthenticationURI(VCloudVersionsAsyncClient versionService, - @Named(PROPERTY_API_VERSION) String version) { - return URI.create("https://vcloud/login"); - } - - @Override - protected void configure() { - super.configure(); - bind(OrgNameToKeysListSupplier.class).to(TestOrgNameToKeysListSupplier.class); - bind(OrgMapSupplier.class).to(TestTerremarkOrgMapSupplier.class); - bind(OrgCatalogSupplier.class).to(TestOrgCatalogSupplier.class); - bind(OrgCatalogItemSupplier.class).to(TestOrgCatalogItemSupplier.class); - bind(OrgVDCSupplier.class).to(TestTerremarkOrgVDCSupplier.class); - } - - @Singleton - public static class TestOrgNameToKeysListSupplier extends OrgNameToKeysListSupplier { - @Inject - protected TestOrgNameToKeysListSupplier(Supplier sessionSupplier) { - super(sessionSupplier, null); - } - - @Override - public Map get() { - return Maps.transformValues(sessionSupplier.get().getOrgs(), new Function() { - - @Override - public ReferenceType apply(ReferenceType from) { - return new ReferenceTypeImpl(from.getName(), TerremarkECloudMediaType.KEYSLIST_XML, URI.create(from - .getHref().toASCIIString() + "/keysList")); - } - }); - } - } - - @Singleton - public static class TestTerremarkOrgMapSupplier extends OrgMapSupplier { - @Inject - protected TestTerremarkOrgMapSupplier() { - super(null, null); - } - - @Override - public Map get() { - return ImmutableMap. of( - "org", - new TerremarkOrgImpl("org", null, URI.create("https://vcloud.safesecureweb.com/api/v0.8/org/1"), - null, ImmutableMap. of( - "catalog", - new ReferenceTypeImpl("catalog", TerremarkECloudMediaType.CATALOG_XML, URI - .create("https://vcloud.safesecureweb.com/api/v0.8/catalog/1"))), ImmutableMap - . of( - "vdc", - new ReferenceTypeImpl("vdc", TerremarkECloudMediaType.VDC_XML, URI - .create("https://vcloud.safesecureweb.com/api/v0.8/vdc/1"))), ImmutableMap - . of(), new ReferenceTypeImpl("tasksList", - TerremarkECloudMediaType.TASKSLIST_XML, URI - .create("https://vcloud.safesecureweb.com/api/v0.8/tasksList/1")), - new ReferenceTypeImpl("keysList", TerremarkECloudMediaType.KEYSLIST_XML, URI - .create("https://vcloud.safesecureweb.com/api/v0.8/keysList/1")))); - } - } - - @Override - protected URI provideOrg(@org.jclouds.vcloud.endpoints.Org Iterable orgs) { - return URI.create("https://org"); - } - - @Override - protected String provideOrgName(@org.jclouds.vcloud.endpoints.Org Iterable orgs) { - return "org"; - } - - @Override - protected URI provideCatalog(Org org, @Named(PROPERTY_IDENTITY) String user, WriteableCatalog write) { - return URI.create("https://catalog"); - } - - @Override - protected Org provideOrg(CommonVCloudClient discovery) { - return null; - } - - @Override - protected Iterable provideOrgs(Supplier cache, @Named(PROPERTY_IDENTITY) String user) { - return null; - } - - @Override - protected URI provideDefaultTasksList(Org org) { - return URI.create("https://taskslist"); - } - - @Override - protected URI provideDefaultVDC(Org org, @org.jclouds.vcloud.endpoints.VDC String defaultVDC) { - return URI.create("https://vdc/1"); - } - - @Override - protected String provideDefaultVDCName( - @org.jclouds.vcloud.endpoints.VDC Supplier> vDCtoOrgSupplier) { - return "vdc"; - } - - @Override - protected URI provideDefaultNetwork(URI vdc, Injector injector) { - return URI.create("https://vcloud.safesecureweb.com/network/1990"); - } - } - - @Singleton - public static class TestTerremarkOrgVDCSupplier extends OrgVDCSupplier { - @Inject - protected TestTerremarkOrgVDCSupplier() { - super(null, null); - } - - @Override - public Map> get() { - return ImmutableMap.> of("org", - - ImmutableMap. of( - "vdc", - new TerremarkVDCImpl("vdc", null, URI.create("https://vcloud.safesecureweb.com/api/v0.8/vdc/1"), - VDCStatus.READY, null, "description", ImmutableSet. of(), AllocationModel.UNRECOGNIZED, - new Capacity("MB", 0, 0, 0, 0), new Capacity("MB", 0, 0, 0, 0), new Capacity("MB", 0, 0, 0, 0), - ImmutableMap. of( - "vapp", - new ReferenceTypeImpl("vapp", "application/vnd.vmware.vcloud.vApp+xml", URI - .create("https://vcloud.safesecureweb.com/api/v0.8/vApp/188849-1")), - "network", - new ReferenceTypeImpl("network", "application/vnd.vmware.vcloud.vAppTemplate+xml", URI - .create("https://vcloud.safesecureweb.com/api/v0.8/vdcItem/2"))), ImmutableMap - . of(), 0, 0, 0, false, new ReferenceTypeImpl("catalog", - TerremarkVCloudMediaType.CATALOG_XML, URI - .create("https://vcloud.safesecureweb.com/api/v0.8/catalog/1")), - new ReferenceTypeImpl("publicIps", TerremarkVCloudMediaType.PUBLICIPSLIST_XML, URI - .create("https://vcloud.safesecureweb.com/api/v0.8/publicIps/1")), new ReferenceTypeImpl( - "internetServices", TerremarkVCloudMediaType.INTERNETSERVICESLIST_XML, URI - .create("https://vcloud.safesecureweb.com/api/v0.8/internetServices/1"))))); - } - } } diff --git a/providers/trmk-ecloud/src/test/java/org/jclouds/vcloud/terremark/compute/functions/TerremarkECloudParseOsFromVAppTemplateNameTest.java b/providers/trmk-ecloud/src/test/java/org/jclouds/vcloud/terremark/compute/functions/TerremarkECloudParseOsFromVAppTemplateNameTest.java index d96827fac5..284ff1be22 100644 --- a/providers/trmk-ecloud/src/test/java/org/jclouds/vcloud/terremark/compute/functions/TerremarkECloudParseOsFromVAppTemplateNameTest.java +++ b/providers/trmk-ecloud/src/test/java/org/jclouds/vcloud/terremark/compute/functions/TerremarkECloudParseOsFromVAppTemplateNameTest.java @@ -24,7 +24,7 @@ import java.io.InputStream; import java.util.Map; import java.util.Set; -import org.jclouds.compute.domain.OperatingSystemBuilder; +import org.jclouds.compute.domain.OperatingSystem; import org.jclouds.compute.domain.OsFamily; import org.jclouds.compute.reference.ComputeServiceConstants; import org.jclouds.http.functions.ParseSax; @@ -66,100 +66,100 @@ public class TerremarkECloudParseOsFromVAppTemplateNameTest { assertEquals(Sets.newLinkedHashSet(Iterables.transform(names, function)), ImmutableSet.of( // CentOS 5 (x64) - new OperatingSystemBuilder().family(OsFamily.CENTOS).version("5.0").description("CentOS 5 (x64)") + new OperatingSystem.Builder().family(OsFamily.CENTOS).version("5.0").description("CentOS 5 (x64)") .is64Bit(true).build(), // CentOS 5 (x86) - new OperatingSystemBuilder().family(OsFamily.CENTOS).version("5.0").description("CentOS 5 (x86)") + new OperatingSystem.Builder().family(OsFamily.CENTOS).version("5.0").description("CentOS 5 (x86)") .is64Bit(false).build(), // CentOS 5.5 x32 - new OperatingSystemBuilder().family(OsFamily.CENTOS).version("5.5").description("CentOS 5.5 x32") + new OperatingSystem.Builder().family(OsFamily.CENTOS).version("5.5").description("CentOS 5.5 x32") .is64Bit(false).build(), // CentOS 5.5 x64 - new OperatingSystemBuilder().family(OsFamily.CENTOS).version("5.5").description("CentOS 5.5 x64") + new OperatingSystem.Builder().family(OsFamily.CENTOS).version("5.5").description("CentOS 5.5 x64") .is64Bit(true).build(), // Red Hat Enterprise Linux 5 (x64) - new OperatingSystemBuilder().family(OsFamily.RHEL).version("5.0").description( + new OperatingSystem.Builder().family(OsFamily.RHEL).version("5.0").description( "Red Hat Enterprise Linux 5 (x64)").is64Bit(true).build(), // Red Hat Enterprise Linux 5 (x86) - new OperatingSystemBuilder().family(OsFamily.RHEL).version("5.0").description( + new OperatingSystem.Builder().family(OsFamily.RHEL).version("5.0").description( "Red Hat Enterprise Linux 5 (x86)").is64Bit(false).build(), // Red Hat Enterprise Linux 5.5 x32 - new OperatingSystemBuilder().family(OsFamily.RHEL).version("5.5").description( + new OperatingSystem.Builder().family(OsFamily.RHEL).version("5.5").description( "Red Hat Enterprise Linux 5.5 x32").is64Bit(false).build(), // Red Hat Enterprise Linux 5.5 x64 - new OperatingSystemBuilder().family(OsFamily.RHEL).version("5.5").description( + new OperatingSystem.Builder().family(OsFamily.RHEL).version("5.5").description( "Red Hat Enterprise Linux 5.5 x64").is64Bit(true).build(), // Sun Solaris 10 (x64) - new OperatingSystemBuilder().family(OsFamily.SOLARIS).version("10").description("Sun Solaris 10 (x64)") + new OperatingSystem.Builder().family(OsFamily.SOLARIS).version("10").description("Sun Solaris 10 (x64)") .is64Bit(true).build(), // Ubuntu 8.04 LTS (x64) - new OperatingSystemBuilder().family(OsFamily.UBUNTU).version("8.04") + new OperatingSystem.Builder().family(OsFamily.UBUNTU).version("8.04") .description("Ubuntu 8.04 LTS (x64)").is64Bit(true).build(), // Ubuntu 8.04 LTS (x86) - new OperatingSystemBuilder().family(OsFamily.UBUNTU).version("8.04") + new OperatingSystem.Builder().family(OsFamily.UBUNTU).version("8.04") .description("Ubuntu 8.04 LTS (x86)").is64Bit(false).build(), // Ubuntu Server 10.04 x32 - new OperatingSystemBuilder().family(OsFamily.UBUNTU).version("10.04").description( + new OperatingSystem.Builder().family(OsFamily.UBUNTU).version("10.04").description( "Ubuntu Server 10.04 x32").is64Bit(false).build(), // Ubuntu Server 10.04 x64 - new OperatingSystemBuilder().family(OsFamily.UBUNTU).version("10.04").description( + new OperatingSystem.Builder().family(OsFamily.UBUNTU).version("10.04").description( "Ubuntu Server 10.04 x64").is64Bit(true).build(), // -Windows 2003 Std. R2 SQL 2005 Std. (x64) - new OperatingSystemBuilder().family(OsFamily.WINDOWS).version("2003 R2").description( + new OperatingSystem.Builder().family(OsFamily.WINDOWS).version("2003 R2").description( "-Windows 2003 Std. R2 SQL 2005 Std. (x64)").is64Bit(true).build(), // -Windows 2003 Std. R2 SQL 2008 Std. (x64) - new OperatingSystemBuilder().family(OsFamily.WINDOWS).version("2003 R2").description( + new OperatingSystem.Builder().family(OsFamily.WINDOWS).version("2003 R2").description( "-Windows 2003 Std. R2 SQL 2008 Std. (x64)").is64Bit(true).build(), // -Windows 2008 R2 Std wSQL 2008 R2 Std (x64) - new OperatingSystemBuilder().family(OsFamily.WINDOWS).version("2008 R2").description( + new OperatingSystem.Builder().family(OsFamily.WINDOWS).version("2008 R2").description( "-Windows 2008 R2 Std wSQL 2008 R2 Std (x64)").is64Bit(true).build(), // -Windows 2008 R2 Std wSQL 2008 R2 Web (x64) - new OperatingSystemBuilder().family(OsFamily.WINDOWS).version("2008 R2").description( + new OperatingSystem.Builder().family(OsFamily.WINDOWS).version("2008 R2").description( "-Windows 2008 R2 Std wSQL 2008 R2 Web (x64)").is64Bit(true).build(), // -Windows 2008 Std wSQL 2008 Std (x64) - new OperatingSystemBuilder().family(OsFamily.WINDOWS).version("2008").description( + new OperatingSystem.Builder().family(OsFamily.WINDOWS).version("2008").description( "-Windows 2008 Std wSQL 2008 Std (x64)").is64Bit(true).build(), // -Windows 2008 Std wSQL 2008 Web (x64) - new OperatingSystemBuilder().family(OsFamily.WINDOWS).version("2008").description( + new OperatingSystem.Builder().family(OsFamily.WINDOWS).version("2008").description( "-Windows 2008 Std wSQL 2008 Web (x64)").is64Bit(true).build(), // -Windows Server 2003 R2 Enterprise Edition (x64) - new OperatingSystemBuilder().family(OsFamily.WINDOWS).version("2003 R2").description( + new OperatingSystem.Builder().family(OsFamily.WINDOWS).version("2003 R2").description( "-Windows Server 2003 R2 Enterprise Edition (x64)").is64Bit(true).build(), // -Windows Server 2003 R2 Enterprise Edition (x86) - new OperatingSystemBuilder().family(OsFamily.WINDOWS).version("2003 R2").description( + new OperatingSystem.Builder().family(OsFamily.WINDOWS).version("2003 R2").description( "-Windows Server 2003 R2 Enterprise Edition (x86)").is64Bit(false).build(), // -Windows Server 2003 R2 Standard Edition (x64) - new OperatingSystemBuilder().family(OsFamily.WINDOWS).version("2003 R2").description( + new OperatingSystem.Builder().family(OsFamily.WINDOWS).version("2003 R2").description( "-Windows Server 2003 R2 Standard Edition (x64)").is64Bit(true).build(), // -Windows Server 2003 R2 Standard Edition (x86) - new OperatingSystemBuilder().family(OsFamily.WINDOWS).version("2003 R2").description( + new OperatingSystem.Builder().family(OsFamily.WINDOWS).version("2003 R2").description( "-Windows Server 2003 R2 Standard Edition (x86)").is64Bit(false).build(), // -Windows Server 2008 Enterprise Edition (x64) - new OperatingSystemBuilder().family(OsFamily.WINDOWS).version("2008").description( + new OperatingSystem.Builder().family(OsFamily.WINDOWS).version("2008").description( "-Windows Server 2008 Enterprise Edition (x64)").is64Bit(true).build(), // -Windows Server 2008 Enterprise Edition (x86) - new OperatingSystemBuilder().family(OsFamily.WINDOWS).version("2008").description( + new OperatingSystem.Builder().family(OsFamily.WINDOWS).version("2008").description( "-Windows Server 2008 Enterprise Edition (x86)").is64Bit(false).build(), // -Windows Server 2008 R2 Enterprise Edition (x64) - new OperatingSystemBuilder().family(OsFamily.WINDOWS).version("2008 R2").description( + new OperatingSystem.Builder().family(OsFamily.WINDOWS).version("2008 R2").description( "-Windows Server 2008 R2 Enterprise Edition (x64)").is64Bit(true).build(), // -Windows Server 2008 R2 Standard Edition (x64) - new OperatingSystemBuilder().family(OsFamily.WINDOWS).version("2008 R2").description( + new OperatingSystem.Builder().family(OsFamily.WINDOWS).version("2008 R2").description( "-Windows Server 2008 R2 Standard Edition (x64)").is64Bit(true).build(), // -Windows Server 2008 R2 Web Edition (x64) - new OperatingSystemBuilder().family(OsFamily.WINDOWS).version("2008 R2").description( + new OperatingSystem.Builder().family(OsFamily.WINDOWS).version("2008 R2").description( "-Windows Server 2008 R2 Web Edition (x64)").is64Bit(true).build(), // -Windows Server 2008 Standard Edition (x64) - new OperatingSystemBuilder().family(OsFamily.WINDOWS).version("2008").description( + new OperatingSystem.Builder().family(OsFamily.WINDOWS).version("2008").description( "-Windows Server 2008 Standard Edition (x64)").is64Bit(true).build(), // -Windows Server 2008 Standard Edition (x86) - new OperatingSystemBuilder().family(OsFamily.WINDOWS).version("2008").description( + new OperatingSystem.Builder().family(OsFamily.WINDOWS).version("2008").description( "-Windows Server 2008 Standard Edition (x86)").is64Bit(false).build(), // -Windows Server 2008 Web Edition (x64) - new OperatingSystemBuilder().family(OsFamily.WINDOWS).version("2008").description( + new OperatingSystem.Builder().family(OsFamily.WINDOWS).version("2008").description( "-Windows Server 2008 Web Edition (x64)").is64Bit(true).build(), // -Windows Server 2008 Web Edition (x86) - new OperatingSystemBuilder().family(OsFamily.WINDOWS).version("2008").description( + new OperatingSystem.Builder().family(OsFamily.WINDOWS).version("2008").description( "-Windows Server 2008 Web Edition (x86)").is64Bit(false).build() )); diff --git a/providers/trmk-ecloud/src/test/resources/deviceTags.xml b/providers/trmk-ecloud/src/test/resources/deviceTags.xml new file mode 100644 index 0000000000..232a49fedf --- /dev/null +++ b/providers/trmk-ecloud/src/test/resources/deviceTags.xml @@ -0,0 +1,27 @@ + + + + + Tag1 + + 1 + + + + + + Tag2 + + 5 + + + + + + Tag3 + + 12 + + + + \ No newline at end of file diff --git a/providers/trmk-ecloud/src/test/resources/org-ecloud.xml b/providers/trmk-ecloud/src/test/resources/org-ecloud.xml new file mode 100644 index 0000000000..74888a9037 --- /dev/null +++ b/providers/trmk-ecloud/src/test/resources/org-ecloud.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/providers/trmk-vcloudexpress/src/test/java/org/jclouds/vcloud/terremark/TerremarkVCloudExpressAsyncClientTest.java b/providers/trmk-vcloudexpress/src/test/java/org/jclouds/vcloud/terremark/TerremarkVCloudExpressAsyncClientTest.java index 4c9147604e..395bdcdb69 100644 --- a/providers/trmk-vcloudexpress/src/test/java/org/jclouds/vcloud/terremark/TerremarkVCloudExpressAsyncClientTest.java +++ b/providers/trmk-vcloudexpress/src/test/java/org/jclouds/vcloud/terremark/TerremarkVCloudExpressAsyncClientTest.java @@ -48,9 +48,9 @@ import org.jclouds.rest.functions.ReturnVoidOnNotFoundOr404; import org.jclouds.rest.internal.RestAnnotationProcessor; import org.jclouds.util.Strings2; import org.jclouds.vcloud.CommonVCloudClient; -import org.jclouds.vcloud.VCloudVersionsAsyncClient; import org.jclouds.vcloud.VCloudExpressAsyncClientTest.VCloudRestClientModuleExtension.TestOrgCatalogItemSupplier; import org.jclouds.vcloud.VCloudExpressAsyncClientTest.VCloudRestClientModuleExtension.TestOrgCatalogSupplier; +import org.jclouds.vcloud.VCloudVersionsAsyncClient; import org.jclouds.vcloud.domain.AllocationModel; import org.jclouds.vcloud.domain.Capacity; import org.jclouds.vcloud.domain.Catalog; @@ -718,9 +718,10 @@ public class TerremarkVCloudExpressAsyncClientTest extends RestClientTest of(), new ReferenceTypeImpl("tasksList", - TerremarkVCloudExpressMediaType.TASKSLIST_XML, URI - .create("https://vcloud.safesecureweb.com/api/v0.8/tasksList/1")), + . of(), ImmutableMap. of( + "tasksList", + new ReferenceTypeImpl("tasksList", TerremarkVCloudExpressMediaType.TASKSLIST_XML, URI + .create("https://vcloud.safesecureweb.com/api/v0.8/tasksList/1"))), new ReferenceTypeImpl("keysList", TerremarkVCloudExpressMediaType.KEYSLIST_XML, URI .create("https://vcloud.safesecureweb.com/api/v0.8/keysList/1")))); } From dddbd1049046f80675240c922c1bcdbf2dabceca Mon Sep 17 00:00:00 2001 From: Adrian Cole Date: Wed, 20 Jul 2011 23:51:02 +1000 Subject: [PATCH 131/264] eagerly check null on constructor --- .../jclouds/concurrent/RetryOnTimeOutExceptionSupplier.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/core/src/main/java/org/jclouds/concurrent/RetryOnTimeOutExceptionSupplier.java b/core/src/main/java/org/jclouds/concurrent/RetryOnTimeOutExceptionSupplier.java index c881bc55fa..75ddc07708 100644 --- a/core/src/main/java/org/jclouds/concurrent/RetryOnTimeOutExceptionSupplier.java +++ b/core/src/main/java/org/jclouds/concurrent/RetryOnTimeOutExceptionSupplier.java @@ -18,6 +18,7 @@ */ package org.jclouds.concurrent; +import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Throwables.propagate; import java.util.concurrent.TimeoutException; @@ -34,7 +35,7 @@ public class RetryOnTimeOutExceptionSupplier implements Supplier { private final Supplier delegate; public RetryOnTimeOutExceptionSupplier(Supplier delegate) { - this.delegate = delegate; + this.delegate = checkNotNull(delegate, "delegate"); } @Override From b09c81177bd915d148fe80994394348d2e187d06 Mon Sep 17 00:00:00 2001 From: Adrian Cole Date: Fri, 22 Jul 2011 10:35:48 +1000 Subject: [PATCH 132/264] added function to get a configuration property without binding to Guice explicitly --- .../config/ValueOfConfigurationKeyOrNull.java | 55 ++++++++++++++++++ .../ValueOfConfigurationKeyOrNullTest.java | 57 +++++++++++++++++++ 2 files changed, 112 insertions(+) create mode 100644 core/src/main/java/org/jclouds/config/ValueOfConfigurationKeyOrNull.java create mode 100644 core/src/test/java/org/jclouds/config/ValueOfConfigurationKeyOrNullTest.java diff --git a/core/src/main/java/org/jclouds/config/ValueOfConfigurationKeyOrNull.java b/core/src/main/java/org/jclouds/config/ValueOfConfigurationKeyOrNull.java new file mode 100644 index 0000000000..e894899c47 --- /dev/null +++ b/core/src/main/java/org/jclouds/config/ValueOfConfigurationKeyOrNull.java @@ -0,0 +1,55 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.jclouds.config; + +import static com.google.common.base.Preconditions.checkNotNull; + +import javax.inject.Inject; +import javax.inject.Singleton; + +import com.google.common.base.Function; +import com.google.inject.ConfigurationException; +import com.google.inject.Injector; +import com.google.inject.Key; +import com.google.inject.name.Names; + +/** + * + * @author Adrian Cole + */ +@Singleton +public class ValueOfConfigurationKeyOrNull implements Function { + protected final Injector injector; + + @Inject + public ValueOfConfigurationKeyOrNull(Injector injector) { + this.injector = checkNotNull(injector, "injector"); + } + + @Override + public String apply(String configurationKey) { + checkNotNull(configurationKey, "configurationKey"); + try { + return injector.getInstance(Key.get(String.class, Names.named(configurationKey))); + } catch (ConfigurationException e) { + return null; + } + } + +} \ No newline at end of file diff --git a/core/src/test/java/org/jclouds/config/ValueOfConfigurationKeyOrNullTest.java b/core/src/test/java/org/jclouds/config/ValueOfConfigurationKeyOrNullTest.java new file mode 100644 index 0000000000..dc2c8bf35c --- /dev/null +++ b/core/src/test/java/org/jclouds/config/ValueOfConfigurationKeyOrNullTest.java @@ -0,0 +1,57 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.jclouds.config; + +import static org.testng.Assert.assertEquals; + +import java.util.concurrent.ExecutionException; + +import org.testng.annotations.Test; + +import com.google.inject.AbstractModule; +import com.google.inject.Guice; +import com.google.inject.name.Names; + +/** + * Tests behavior of ValueOfConfigurationKeyOrNull + * + * @author Adrian Cole + */ +@Test(groups = "unit") +public class ValueOfConfigurationKeyOrNullTest { + + @Test + public void testNotThere() throws InterruptedException, ExecutionException { + assertEquals(new ValueOfConfigurationKeyOrNull(Guice.createInjector()).apply("foo"), null); + } + + @Test + public void testThere() throws InterruptedException, ExecutionException { + assertEquals(new ValueOfConfigurationKeyOrNull(Guice.createInjector(new AbstractModule() { + + @Override + protected void configure() { + bindConstant().annotatedWith(Names.named("foo")).to("bar"); + } + + })).apply("foo"), "bar"); + + } + +} From f3a0e6d0bda82e2659c10b1a779b8506b9395806 Mon Sep 17 00:00:00 2001 From: Adrian Cole Date: Fri, 22 Jul 2011 10:41:43 +1000 Subject: [PATCH 133/264] Issue 632:enhance and automatically work around nodes with sftp problems --- .../jclouds/ssh/ChannelNotOpenException.java | 45 ++++++++ .../org/jclouds/ssh/jsch/JschSshClient.java | 100 +++++++++++------- .../TerremarkECloudPropertiesBuilder.java | 3 - 3 files changed, 106 insertions(+), 42 deletions(-) create mode 100644 compute/src/main/java/org/jclouds/ssh/ChannelNotOpenException.java diff --git a/compute/src/main/java/org/jclouds/ssh/ChannelNotOpenException.java b/compute/src/main/java/org/jclouds/ssh/ChannelNotOpenException.java new file mode 100644 index 0000000000..b0279519b5 --- /dev/null +++ b/compute/src/main/java/org/jclouds/ssh/ChannelNotOpenException.java @@ -0,0 +1,45 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.jclouds.ssh; + +/** + * @author Adrian Cole + */ +public class ChannelNotOpenException extends SshException { + + /** The serialVersionUID */ + private static final long serialVersionUID = 129347129837129837l; + + public ChannelNotOpenException() { + super(); + } + + public ChannelNotOpenException(String arg0, Throwable arg1) { + super(arg0, arg1); + } + + public ChannelNotOpenException(String arg0) { + super(arg0); + } + + public ChannelNotOpenException(Throwable arg0) { + super(arg0); + } + +} \ No newline at end of file diff --git a/drivers/jsch/src/main/java/org/jclouds/ssh/jsch/JschSshClient.java b/drivers/jsch/src/main/java/org/jclouds/ssh/jsch/JschSshClient.java index f46dec95d3..f5b4cda3dc 100644 --- a/drivers/jsch/src/main/java/org/jclouds/ssh/jsch/JschSshClient.java +++ b/drivers/jsch/src/main/java/org/jclouds/ssh/jsch/JschSshClient.java @@ -45,6 +45,7 @@ import org.jclouds.io.Payload; import org.jclouds.io.Payloads; import org.jclouds.logging.Logger; import org.jclouds.net.IPSocket; +import org.jclouds.ssh.ChannelNotOpenException; import org.jclouds.ssh.SshClient; import org.jclouds.ssh.SshException; import org.jclouds.util.Strings2; @@ -58,6 +59,7 @@ import com.google.inject.Inject; import com.jcraft.jsch.ChannelExec; import com.jcraft.jsch.ChannelSftp; import com.jcraft.jsch.JSch; +import com.jcraft.jsch.JSchException; import com.jcraft.jsch.Session; /** @@ -114,7 +116,7 @@ public class JschSshClient implements SshClient { private final BackoffLimitedRetryHandler backoffLimitedRetryHandler; public JschSshClient(BackoffLimitedRetryHandler backoffLimitedRetryHandler, IPSocket socket, int timeout, - String username, String password, byte[] privateKey) { + String username, String password, byte[] privateKey) { this.host = checkNotNull(socket, "socket").getAddress(); checkArgument(socket.getPort() > 0, "ssh port must be greater then zero" + socket.getPort()); checkArgument(password != null || privateKey != null, "you must specify a password or a key"); @@ -222,10 +224,15 @@ public class JschSshClient implements SshClient { } @Override - public ChannelSftp create() throws Exception { + public ChannelSftp create() throws JSchException { checkConnected(); - sftp = (ChannelSftp) session.openChannel("sftp"); - sftp.connect(); + String channel = "sftp"; + sftp = (ChannelSftp) session.openChannel(channel); + try { + sftp.connect(); + } catch (JSchException e) { + throwChannelNotOpenExceptionOrPropagate(channel, e); + } return sftp; } @@ -235,6 +242,11 @@ public class JschSshClient implements SshClient { } }; + public void throwChannelNotOpenExceptionOrPropagate(String channel, JSchException e) throws JSchException { + if (e.getMessage().indexOf("channel is not opened") != -1) + throw new ChannelNotOpenException(String.format("(%s) channel %s is not open", toString() , channel), e); + } + class GetConnection implements Connection { private final String path; private ChannelSftp sftp; @@ -285,7 +297,7 @@ public class JschSshClient implements SshClient { public Void create() throws Exception { sftp = acquire(sftpConnection); try { - sftp.put(contents.getInput(), path); + sftp.put(checkNotNull(contents.getInput(), "inputstream for path %s", path), path); } finally { Closeables.closeQuietly(contents); clear(); @@ -307,15 +319,17 @@ public class JschSshClient implements SshClient { @VisibleForTesting boolean shouldRetry(Exception from) { final String rootMessage = getRootCause(from).getMessage(); + if (rootMessage == null) + return false; return any(getCausalChain(from), retryPredicate) - || Iterables.any(Splitter.on(",").split(retryableMessages), new Predicate() { + || Iterables.any(Splitter.on(",").split(retryableMessages), new Predicate() { - @Override - public boolean apply(String input) { - return rootMessage.indexOf(input) != -1; - } + @Override + public boolean apply(String input) { + return rootMessage.indexOf(input) != -1; + } - }); + }); } private void backoffForAttempt(int retryAttempt, String message) { @@ -325,7 +339,8 @@ public class JschSshClient implements SshClient { private SshException propagate(Exception e, String message) { message += ": " + e.getMessage(); logger.error(e, "<< " + message); - throw new SshException(message, e); + throw e instanceof SshException ? SshException.class.cast(e) : new SshException( + "(" + toString() + ") " + message, e); } @Override @@ -338,30 +353,42 @@ public class JschSshClient implements SshClient { sessionConnection.clear(); } - Connection execConnection = new Connection() { + protected Connection execConnection(final String command) { + checkNotNull(command, "command"); + return new Connection() { - private ChannelExec executor = null; + private ChannelExec executor = null; - @Override - public void clear() { - if (executor != null) - executor.disconnect(); - } + @Override + public void clear() { + if (executor != null) + executor.disconnect(); + } - @Override - public ChannelExec create() throws Exception { - checkConnected(); - executor = (ChannelExec) session.openChannel("exec"); - executor.setPty(true); - return executor; - } + @Override + public ChannelExec create() throws Exception { + checkConnected(); + String channel = "exec"; + executor = (ChannelExec) session.openChannel(channel); + executor.setPty(true); + executor.setCommand(command); + ByteArrayOutputStream error = new ByteArrayOutputStream(); + executor.setErrStream(error); + try { + executor.connect(); + } catch (JSchException e) { + throwChannelNotOpenExceptionOrPropagate("exec", e); + } + return executor; + } - @Override - public String toString() { - return "ChannelExec(" + JschSshClient.this.toString() + ")"; - } + @Override + public String toString() { + return "ChannelExec(" + JschSshClient.this.toString() + ")"; + } + }; - }; + } class ExecConnection implements Connection { private final String command; @@ -379,14 +406,10 @@ public class JschSshClient implements SshClient { @Override public ExecResponse create() throws Exception { - executor = acquire(execConnection); - executor.setCommand(command); - ByteArrayOutputStream error = new ByteArrayOutputStream(); - executor.setErrStream(error); + executor = acquire(execConnection(command)); try { - executor.connect(); String outputString = Strings2.toStringAndClose(executor.getInputStream()); - String errorString = error.toString(); + String errorString = executor.getErrStream().toString(); int errorStatus = executor.getExitStatus(); int i = 0; String message = String.format("bad status -1 %s", toString()); @@ -407,8 +430,7 @@ public class JschSshClient implements SshClient { public String toString() { return "ExecResponse(" + JschSshClient.this.toString() + ")[" + command + "]"; } - - }; + } public ExecResponse exec(String command) { return acquire(new ExecConnection(command)); diff --git a/providers/trmk-ecloud/src/main/java/org/jclouds/vcloud/terremark/TerremarkECloudPropertiesBuilder.java b/providers/trmk-ecloud/src/main/java/org/jclouds/vcloud/terremark/TerremarkECloudPropertiesBuilder.java index 129f404f68..9c3a33e3b6 100644 --- a/providers/trmk-ecloud/src/main/java/org/jclouds/vcloud/terremark/TerremarkECloudPropertiesBuilder.java +++ b/providers/trmk-ecloud/src/main/java/org/jclouds/vcloud/terremark/TerremarkECloudPropertiesBuilder.java @@ -21,7 +21,6 @@ package org.jclouds.vcloud.terremark; import static org.jclouds.Constants.PROPERTY_API_VERSION; import static org.jclouds.Constants.PROPERTY_ENDPOINT; import static org.jclouds.Constants.PROPERTY_ISO3166_CODES; -import static org.jclouds.compute.callables.RunScriptOnNodeAsInitScriptUsingSsh.PROPERTY_PUSH_INIT_SCRIPT_VIA_SFTP; import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_TIMEOUT_TASK_COMPLETED; import static org.jclouds.vcloud.terremark.reference.TerremarkConstants.PROPERTY_TERREMARK_EXTENSION_NAME; import static org.jclouds.vcloud.terremark.reference.TerremarkConstants.PROPERTY_TERREMARK_EXTENSION_VERSION; @@ -44,8 +43,6 @@ public class TerremarkECloudPropertiesBuilder extends TerremarkVCloudPropertiesB properties.setProperty(PROPERTY_TERREMARK_EXTENSION_VERSION, "2.8"); // default for ubuntu properties.setProperty(PROPERTY_VCLOUD_TIMEOUT_TASK_COMPLETED, 360l * 1000l + ""); - // ubuntu image has a problem with sftp - properties.setProperty(PROPERTY_PUSH_INIT_SCRIPT_VIA_SFTP, "false"); return properties; } From 0921cea2c7a774a7cb3324092bdcf1473511c0a3 Mon Sep 17 00:00:00 2001 From: Adrian Cole Date: Fri, 22 Jul 2011 10:42:37 +1000 Subject: [PATCH 134/264] make test singlethreaded to avoid surefire hangs --- .../org/jclouds/cloudservers/CloudServersAsyncClientTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apis/cloudservers/src/test/java/org/jclouds/cloudservers/CloudServersAsyncClientTest.java b/apis/cloudservers/src/test/java/org/jclouds/cloudservers/CloudServersAsyncClientTest.java index 049648e646..c4129d3825 100644 --- a/apis/cloudservers/src/test/java/org/jclouds/cloudservers/CloudServersAsyncClientTest.java +++ b/apis/cloudservers/src/test/java/org/jclouds/cloudservers/CloudServersAsyncClientTest.java @@ -79,7 +79,7 @@ import com.google.inject.TypeLiteral; * @author Adrian Cole */ // NOTE:without testName, this will not call @Before* and fail w/NPE during surefire -@Test(groups = "unit", testName = "CloudServersAsyncClientTest") +@Test(groups = "unit", singleThreaded=true, testName = "CloudServersAsyncClientTest") public class CloudServersAsyncClientTest extends RestClientTest { private static final Class listOptionsVarargsClass = new ListOptions[] {}.getClass(); private static final Class createServerOptionsVarargsClass = new CreateServerOptions[] {} From ee797da00461ef6ba6acb3c1bf7c91b3a962756b Mon Sep 17 00:00:00 2001 From: Adrian Cole Date: Fri, 22 Jul 2011 10:43:19 +1000 Subject: [PATCH 135/264] Issue 632:enhance and automatically work around nodes with sftp problems --- .../RunScriptOnNodeAsInitScriptUsingSsh.java | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/compute/src/main/java/org/jclouds/compute/callables/RunScriptOnNodeAsInitScriptUsingSsh.java b/compute/src/main/java/org/jclouds/compute/callables/RunScriptOnNodeAsInitScriptUsingSsh.java index 1e53468445..12dba5d327 100644 --- a/compute/src/main/java/org/jclouds/compute/callables/RunScriptOnNodeAsInitScriptUsingSsh.java +++ b/compute/src/main/java/org/jclouds/compute/callables/RunScriptOnNodeAsInitScriptUsingSsh.java @@ -40,6 +40,7 @@ import org.jclouds.scriptbuilder.domain.Statement; import org.jclouds.scriptbuilder.domain.Statements; import org.jclouds.scriptbuilder.statements.login.AdminAccess; import org.jclouds.ssh.SshClient; +import org.jclouds.ssh.SshException; import com.google.common.annotations.VisibleForTesting; import com.google.common.base.Function; @@ -54,7 +55,6 @@ import com.google.inject.assistedinject.AssistedInject; * @author Adrian Cole */ public class RunScriptOnNodeAsInitScriptUsingSsh implements RunScriptOnNode { - public static final String PROPERTY_PUSH_INIT_SCRIPT_VIA_SFTP = "jclouds.compute.push-init-script-via-sftp"; public static final String PROPERTY_INIT_SCRIPT_PATTERN = "jclouds.compute.init-script-pattern"; @Resource @Named(ComputeServiceConstants.COMPUTE_LOGGER) @@ -68,14 +68,6 @@ public class RunScriptOnNodeAsInitScriptUsingSsh implements RunScriptOnNode { protected SshClient ssh; - /** - * true to use sftp, false to use ssh. If there's a problem with the sftp configuration, setting - * this to false will help. - */ - @Inject(optional = true) - @Named(PROPERTY_PUSH_INIT_SCRIPT_VIA_SFTP) - private boolean pushInitViaSftp = true; - /** * determines the naming convention of init scripts. * @@ -141,9 +133,11 @@ public class RunScriptOnNodeAsInitScriptUsingSsh implements RunScriptOnNode { * ssh client is initialized through this call. */ protected ExecResponse doCall() { - if (pushInitViaSftp) { + try { ssh.put(initFile, init.render(OsFamily.UNIX)); - } else { + } catch (SshException e) { + // If there's a problem with the sftp configuration, we can try via ssh exec + logger.warn(e, "<< (%s) problem using sftp [%s], attempting via sshexec", ssh.toString(), e.getMessage()); ssh.exec("rm " + initFile); ssh.exec(Statements.appendFile(initFile, Splitter.on('\n').split(init.render(OsFamily.UNIX)), AppendFile.MARKER + "_" + init.getInstanceName()).render(OsFamily.UNIX)); From feaef2b6eb137f1b8a868ee64dc260061921f2f3 Mon Sep 17 00:00:00 2001 From: Adrian Cole Date: Fri, 22 Jul 2011 10:45:26 +1000 Subject: [PATCH 136/264] work around condition where occasionally gogrid is late making credentials available for a newly started server --- .../compute/strategy/FindIpThenCreateNodeInGroup.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/providers/gogrid/src/main/java/org/jclouds/gogrid/compute/strategy/FindIpThenCreateNodeInGroup.java b/providers/gogrid/src/main/java/org/jclouds/gogrid/compute/strategy/FindIpThenCreateNodeInGroup.java index c32d2068ba..4aa5708d08 100644 --- a/providers/gogrid/src/main/java/org/jclouds/gogrid/compute/strategy/FindIpThenCreateNodeInGroup.java +++ b/providers/gogrid/src/main/java/org/jclouds/gogrid/compute/strategy/FindIpThenCreateNodeInGroup.java @@ -24,6 +24,7 @@ import java.security.SecureRandom; import java.util.Map; import java.util.Set; +import javax.annotation.Resource; import javax.inject.Inject; import javax.inject.Singleton; @@ -40,6 +41,7 @@ import org.jclouds.gogrid.domain.PowerCommand; import org.jclouds.gogrid.domain.Server; import org.jclouds.gogrid.options.GetIpListOptions; import org.jclouds.gogrid.predicates.ServerLatestJobCompleted; +import org.jclouds.logging.Logger; import org.jclouds.predicates.RetryablePredicate; import com.google.common.base.Function; @@ -51,6 +53,9 @@ import com.google.common.collect.Iterables; */ @Singleton public class FindIpThenCreateNodeInGroup implements CreateNodeWithGroupEncodedIntoName { + @Resource + protected Logger logger = Logger.NULL; + private final GoGridClient client; private final Function sizeToRam; private final Function serverToNodeMetadata; @@ -108,7 +113,11 @@ public class FindIpThenCreateNodeInGroup implements CreateNodeWithGroupEncodedIn addedServer = Iterables.getOnlyElement(client.getServerServices().getServersByName( addedServer.getName())); } - credentialStore.put("node#" + addedServer.getId(),client.getServerServices().getServerCredentialsList().get(addedServer.getName())); + Credentials credentials = client.getServerServices().getServerCredentialsList().get(addedServer.getName()); + if (credentials != null) + credentialStore.put("node#" + addedServer.getId(), credentials); + else + logger.warn("couldn't get credentials for server %s", addedServer.getName()); return serverToNodeMetadata.apply(addedServer); } From 66626140236aaec2a135c0d2bb234ffbfe8d75f1 Mon Sep 17 00:00:00 2001 From: Adrian Cole Date: Fri, 22 Jul 2011 10:46:09 +1000 Subject: [PATCH 137/264] update slicehost default template properties --- .../slicehost/compute/SlicehostTemplateBuilderLiveTest.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/providers/slicehost/src/test/java/org/jclouds/slicehost/compute/SlicehostTemplateBuilderLiveTest.java b/providers/slicehost/src/test/java/org/jclouds/slicehost/compute/SlicehostTemplateBuilderLiveTest.java index e435c3f949..71eaadb116 100644 --- a/providers/slicehost/src/test/java/org/jclouds/slicehost/compute/SlicehostTemplateBuilderLiveTest.java +++ b/providers/slicehost/src/test/java/org/jclouds/slicehost/compute/SlicehostTemplateBuilderLiveTest.java @@ -53,7 +53,8 @@ public class SlicehostTemplateBuilderLiveTest extends BaseTemplateBuilderLiveTes public boolean apply(OsFamilyVersion64Bit input) { switch (input.family) { case UBUNTU: - return input.version.equals("") || input.version.startsWith("10") || input.version.equals("9.10"); + return !(input.version.startsWith("11.10") || input.version.equals("8.04") || (input.version + .equals("11.04") && !input.is64Bit)); case DEBIAN: return !(input.version.equals("6.0") && !input.is64Bit); case RHEL: @@ -75,7 +76,7 @@ public class SlicehostTemplateBuilderLiveTest extends BaseTemplateBuilderLiveTes @Test public void testDefaultTemplateBuilder() throws IOException { Template defaultTemplate = context.getComputeService().templateBuilder().build(); - assertEquals(defaultTemplate.getImage().getOperatingSystem().getVersion(), "10.10"); + assertEquals(defaultTemplate.getImage().getOperatingSystem().getVersion(), "11.04"); assertEquals(defaultTemplate.getImage().getOperatingSystem().is64Bit(), true); assertEquals(defaultTemplate.getImage().getOperatingSystem().getFamily(), OsFamily.UBUNTU); assertEquals(getCores(defaultTemplate.getHardware()), 0.25d); From c1ae4d06e6277a6897bbdf059eed84f9e7793a66 Mon Sep 17 00:00:00 2001 From: Adrian Cole Date: Fri, 22 Jul 2011 10:46:40 +1000 Subject: [PATCH 138/264] update amazon template to reflect current images --- .../jclouds/aws/ec2/compute/AWSEC2TemplateBuilderLiveTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/compute/AWSEC2TemplateBuilderLiveTest.java b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/compute/AWSEC2TemplateBuilderLiveTest.java index e77caab364..ea74107d69 100644 --- a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/compute/AWSEC2TemplateBuilderLiveTest.java +++ b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/compute/AWSEC2TemplateBuilderLiveTest.java @@ -85,7 +85,7 @@ public class AWSEC2TemplateBuilderLiveTest extends BaseTemplateBuilderLiveTest { .build(); assert (template.getImage().getProviderId().startsWith("ami-")) : template; - assertEquals(template.getImage().getOperatingSystem().getVersion(), "11.10"); + assertEquals(template.getImage().getOperatingSystem().getVersion(), "10.10"); assertEquals(template.getImage().getOperatingSystem().is64Bit(), false); assertEquals(template.getImage().getOperatingSystem().getFamily(), OsFamily.UBUNTU); assertEquals(template.getImage().getUserMetadata().get("rootDeviceType"), "instance-store"); From 0f9dd50d7db6f252a4b9ec477672b78ab7cbf727 Mon Sep 17 00:00:00 2001 From: Adrian Cole Date: Fri, 22 Jul 2011 11:03:29 +1000 Subject: [PATCH 139/264] Issue 628:expose properties to choose default Org and vDC in vCloud-based implementations --- ...antiateVAppTemplateParamsToXmlPayload.java | 9 +- .../config/BaseVCloudRestClientModule.java | 52 +-- .../vcloud/BaseVCloudAsyncClientTest.java | 218 ++++------ .../DeprecatedVCloudClientLiveTest.java | 230 ++++++----- ...ateVAppTemplateParamsToXmlPayloadTest.java | 6 +- .../vcloud/VCloudExpressAsyncClient.java | 13 +- .../jclouds/vcloud/VCloudExpressClient.java | 9 +- ...ExpressVAppTemplateParamsToXmlPayload.java | 7 +- .../VCloudExpressVAppToNodeMetadata.java | 23 +- .../BaseVCloudExpressRestClientModule.java | 18 +- .../internal/VCloudExpressVAppImpl.java | 3 - .../VCloudExpressVAppTemplateImpl.java | 2 - .../internal/VCloudExpressNetworkImpl.java | 2 - .../vcloud/VCloudExpressAsyncClientTest.java | 195 ++++----- .../vcloud/VCloudExpressClientLiveTest.java | 72 ++-- ...essVAppTemplateParamsToXmlPayloadTest.java | 6 +- .../terremark/TerremarkVCloudAsyncClient.java | 10 - .../terremark/TerremarkVCloudClient.java | 11 - ...antiateVAppTemplateParamsToXmlPayload.java | 6 +- .../config/TerremarkRestClientModule.java | 34 +- .../terremark/functions/OrgURIToEndpoint.java | 8 +- .../functions/OrgURIToKeysListEndpoint.java | 3 +- .../VDCURIToInternetServicesEndpoint.java | 9 +- .../functions/VDCURIToPublicIPsEndpoint.java | 8 +- .../terremark/TerremarkClientLiveTest.java | 119 +++--- ...ateVAppTemplateParamsToXmlPayloadTest.java | 6 +- ...mmonVCloudBindComputeSuppliersByClass.java | 54 +++ .../config/CommonVCloudRestClientModule.java | 387 +++++------------- .../vcloud/config/DefaultCatalogForOrg.java | 65 +++ .../vcloud/config/DefaultNetworkForVDC.java | 68 +++ .../vcloud/config/DefaultOrgForUser.java | 64 +++ .../vcloud/config/DefaultTasksListForOrg.java | 55 +++ .../config/DefaultVCloudReferencesModule.java | 175 ++++++++ .../vcloud/config/DefaultVDCForOrg.java | 65 +++ .../domain/internal/CatalogItemImpl.java | 2 - .../vcloud/domain/internal/TasksListImpl.java | 3 - .../OrgNameAndCatalogNameToEndpoint.java | 12 +- .../OrgNameAndVDCNameToEndpoint.java | 12 +- .../OrgNameCatalogNameItemNameToEndpoint.java | 11 +- ...CatalogNameVAppTemplateNameToEndpoint.java | 11 +- .../vcloud/functions/OrgNameToEndpoint.java | 9 +- .../functions/OrgNameToTasksListEndpoint.java | 10 +- ...meVDCNameResourceEntityNameToEndpoint.java | 13 +- .../ParseLoginResponseFromHeaders.java | 4 +- .../vcloud/reference/VCloudConstants.java | 15 +- ...NameMatchingConfigurationKeyOrDefault.java | 101 +++++ .../vcloud/CommonVCloudClientLiveTest.java | 245 +++++++---- ...MatchingConfigurationKeyOrDefaultTest.java | 124 ++++++ ...uelockVCloudDirectorPropertiesBuilder.java | 2 +- ...lockVCloudEnterprisePropertiesBuilder.java | 2 +- ...BluelockVCloudZone01PropertiesBuilder.java | 2 +- providers/trmk-ecloud/pom.xml | 5 + .../OrgURIToDataCentersListEndpoint.java | 3 +- .../functions/OrgURIToTagsListEndpoint.java | 3 +- .../terremark/TerremarkECloudAsyncClient.java | 6 +- .../TerremarkECloudRestClientModule.java | 88 ++-- ...rnetServiceAndPublicIpAddressSupplier.java | 2 +- .../BaseTerremarkECloudAsyncClientTest.java | 352 ++++++++-------- .../BaseTerremarkECloudClientLiveTest.java | 11 +- .../DataCenterOperationsClientLiveTest.java | 2 +- .../features/TagOperationsClientLiveTest.java | 2 +- .../TerremarkECloudAsyncClientTest.java | 20 +- .../TerremarkECloudClientLiveTest.java | 12 +- ...TerremarkECloudComputeServiceLiveTest.java | 28 +- ...erremarkECloudTemplateBuilderLiveTest.java | 37 +- ...TerremarkVCloudExpressAsyncClientTest.java | 284 +++++++------ .../TerremarkVCloudExpressClientLiveTest.java | 18 +- ...rkVCloudExpressComputeServiceLiveTest.java | 7 - 68 files changed, 2160 insertions(+), 1310 deletions(-) create mode 100644 common/vcloud/src/main/java/org/jclouds/vcloud/config/DefaultCatalogForOrg.java create mode 100644 common/vcloud/src/main/java/org/jclouds/vcloud/config/DefaultNetworkForVDC.java create mode 100644 common/vcloud/src/main/java/org/jclouds/vcloud/config/DefaultOrgForUser.java create mode 100644 common/vcloud/src/main/java/org/jclouds/vcloud/config/DefaultTasksListForOrg.java create mode 100644 common/vcloud/src/main/java/org/jclouds/vcloud/config/DefaultVCloudReferencesModule.java create mode 100644 common/vcloud/src/main/java/org/jclouds/vcloud/config/DefaultVDCForOrg.java create mode 100644 common/vcloud/src/main/java/org/jclouds/vcloud/suppliers/OnlyReferenceTypeFirstWithNameMatchingConfigurationKeyOrDefault.java create mode 100644 common/vcloud/src/test/java/org/jclouds/vcloud/suppliers/OnlyReferenceTypeFirstWithNameMatchingConfigurationKeyOrDefaultTest.java diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/binders/BindInstantiateVAppTemplateParamsToXmlPayload.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/binders/BindInstantiateVAppTemplateParamsToXmlPayload.java index 2eb7627e63..22120e49fc 100644 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/binders/BindInstantiateVAppTemplateParamsToXmlPayload.java +++ b/apis/vcloud/src/main/java/org/jclouds/vcloud/binders/BindInstantiateVAppTemplateParamsToXmlPayload.java @@ -44,6 +44,7 @@ import org.jclouds.rest.MapBinder; import org.jclouds.rest.binders.BindToStringPayload; import org.jclouds.rest.internal.GeneratedHttpRequest; import org.jclouds.vcloud.VCloudClient; +import org.jclouds.vcloud.domain.ReferenceType; import org.jclouds.vcloud.domain.VAppTemplate; import org.jclouds.vcloud.domain.Vm; import org.jclouds.vcloud.domain.network.FenceMode; @@ -70,7 +71,7 @@ public class BindInstantiateVAppTemplateParamsToXmlPayload implements MapBinder protected final String ns; protected final String schema; protected final BindToStringPayload stringBinder; - protected final URI defaultNetwork; + protected final ReferenceType defaultNetwork; protected final FenceMode defaultFenceMode; protected final DefaultNetworkNameInTemplate defaultNetworkNameInTemplate; protected final VCloudClient client; @@ -78,7 +79,7 @@ public class BindInstantiateVAppTemplateParamsToXmlPayload implements MapBinder @Inject public BindInstantiateVAppTemplateParamsToXmlPayload(DefaultNetworkNameInTemplate defaultNetworkNameInTemplate, BindToStringPayload stringBinder, @Named(PROPERTY_VCLOUD_XML_NAMESPACE) String ns, - @Named(PROPERTY_VCLOUD_XML_SCHEMA) String schema, @Network URI network, + @Named(PROPERTY_VCLOUD_XML_SCHEMA) String schema, @Network ReferenceType network, @Named(PROPERTY_VCLOUD_DEFAULT_FENCEMODE) String fenceMode, VCloudClient client) { this.defaultNetworkNameInTemplate = defaultNetworkNameInTemplate; this.ns = ns; @@ -104,8 +105,8 @@ public class BindInstantiateVAppTemplateParamsToXmlPayload implements MapBinder Set networkConfig = null; - NetworkConfigDecorator networknetworkConfigDecorator = new NetworkConfigDecorator(template, defaultNetwork, - defaultFenceMode, defaultNetworkNameInTemplate); + NetworkConfigDecorator networknetworkConfigDecorator = new NetworkConfigDecorator(template, + defaultNetwork.getHref(), defaultFenceMode, defaultNetworkNameInTemplate); InstantiateVAppTemplateOptions options = findOptionsInArgsOrNull(gRequest); diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/config/BaseVCloudRestClientModule.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/config/BaseVCloudRestClientModule.java index 60789123aa..0a8d53f7fa 100644 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/config/BaseVCloudRestClientModule.java +++ b/apis/vcloud/src/main/java/org/jclouds/vcloud/config/BaseVCloudRestClientModule.java @@ -23,21 +23,21 @@ import static org.jclouds.Constants.PROPERTY_SESSION_INTERVAL; import java.util.Map; import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicReference; -import javax.inject.Inject; import javax.inject.Named; import javax.inject.Singleton; import org.jclouds.cim.xml.ResourceAllocationSettingDataHandler; import org.jclouds.http.RequiresHttp; import org.jclouds.rest.AsyncClientFactory; +import org.jclouds.rest.AuthorizationException; import org.jclouds.rest.ConfiguresRestClient; import org.jclouds.rest.suppliers.MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier; import org.jclouds.vcloud.VCloudAsyncClient; import org.jclouds.vcloud.VCloudClient; import org.jclouds.vcloud.VCloudLoginAsyncClient; import org.jclouds.vcloud.domain.CatalogItem; -import org.jclouds.vcloud.domain.ReferenceType; import org.jclouds.vcloud.domain.VAppTemplate; import org.jclouds.vcloud.domain.VCloudSession; import org.jclouds.vcloud.functions.VAppTemplatesForCatalogItems; @@ -49,47 +49,31 @@ import com.google.inject.Provides; import com.google.inject.TypeLiteral; /** - * Configures the VCloud authentication service connection, including logging and http transport. + * Configures the VCloud authentication service connection, including logging + * and http transport. * * @author Adrian Cole */ @RequiresHttp @ConfiguresRestClient public abstract class BaseVCloudRestClientModule extends - CommonVCloudRestClientModule { + CommonVCloudRestClientModule { public BaseVCloudRestClientModule(Class syncClientType, Class asyncClientType) { super(syncClientType, asyncClientType); } public BaseVCloudRestClientModule(Class syncClientType, Class asyncClientType, - Map, Class> delegateMap) { + Map, Class> delegateMap) { super(syncClientType, asyncClientType, delegateMap); } - @Singleton - public static class VCloudWritableCatalog extends WriteableCatalog { - private final VCloudClient client; - - @Inject - public VCloudWritableCatalog(VCloudClient client) { - super(client); - this.client = client; - } - - @Override - public boolean apply(ReferenceType arg0) { - return !client.getCatalogClient().getCatalog(arg0.getHref()).isReadOnly(); - } - } - @Override protected void configure() { bind(new TypeLiteral, Iterable>>() { }).to(new TypeLiteral() { }); bind(ResourceAllocationSettingDataHandler.class).to(VCloudResourceAllocationSettingDataHandler.class); - bind(WriteableCatalog.class).to(VCloudWritableCatalog.class); super.configure(); } @@ -102,21 +86,21 @@ public abstract class BaseVCloudRestClientModule provideVCloudTokenCache(@Named(PROPERTY_SESSION_INTERVAL) long seconds, - final VCloudLoginAsyncClient login) { + AtomicReference authException, final VCloudLoginAsyncClient login) { return new MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier(authException, seconds, - new Supplier() { + new Supplier() { - @Override - public VCloudSession get() { - try { - return login.login().get(10, TimeUnit.SECONDS); - } catch (Exception e) { - propagate(e); - assert false : e; - return null; - } + @Override + public VCloudSession get() { + try { + return login.login().get(10, TimeUnit.SECONDS); + } catch (Exception e) { + propagate(e); + assert false : e; + return null; } + } - }); + }); } } diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/BaseVCloudAsyncClientTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/BaseVCloudAsyncClientTest.java index 2de9d696d7..2ccc14f322 100644 --- a/apis/vcloud/src/test/java/org/jclouds/vcloud/BaseVCloudAsyncClientTest.java +++ b/apis/vcloud/src/test/java/org/jclouds/vcloud/BaseVCloudAsyncClientTest.java @@ -18,14 +18,13 @@ */ package org.jclouds.vcloud; -import static org.jclouds.Constants.PROPERTY_API_VERSION; -import static org.jclouds.Constants.PROPERTY_IDENTITY; import static org.jclouds.Constants.PROPERTY_SESSION_INTERVAL; import static org.testng.Assert.assertEquals; import java.net.URI; import java.util.Map; import java.util.Properties; +import java.util.concurrent.atomic.AtomicReference; import javax.inject.Inject; import javax.inject.Named; @@ -33,6 +32,7 @@ import javax.inject.Singleton; import org.jclouds.http.HttpRequest; import org.jclouds.http.RequiresHttp; +import org.jclouds.rest.AuthorizationException; import org.jclouds.rest.ConfiguresRestClient; import org.jclouds.rest.RestClientTest; import org.jclouds.rest.RestContextFactory; @@ -43,6 +43,7 @@ import org.jclouds.vcloud.domain.Org; import org.jclouds.vcloud.domain.ReferenceType; import org.jclouds.vcloud.domain.Task; import org.jclouds.vcloud.domain.VCloudSession; +import org.jclouds.vcloud.domain.VDC; import org.jclouds.vcloud.domain.VDCStatus; import org.jclouds.vcloud.domain.internal.CatalogImpl; import org.jclouds.vcloud.domain.internal.CatalogItemImpl; @@ -57,7 +58,7 @@ import com.google.common.base.Suppliers; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; -import com.google.inject.Injector; +import com.google.inject.AbstractModule; import com.google.inject.Module; /** @@ -88,67 +89,79 @@ public abstract class BaseVCloudAsyncClientTest extends RestClientTest { return new RestContextFactory().createContextSpec("vcloud", "identity", "credential", overrides); } + protected static final ReferenceTypeImpl ORG_REF = new ReferenceTypeImpl("org", VCloudMediaType.ORG_XML, + URI.create("https://vcenterprise.bluelock.com/api/v1.0/org/1")); + + protected static final ReferenceTypeImpl CATALOG_REF = new ReferenceTypeImpl("catalog", VCloudMediaType.CATALOG_XML, + URI.create("https://vcenterprise.bluelock.com/api/v1.0/catalog/1")); + + protected static final ReferenceTypeImpl TASKSLIST_REF = new ReferenceTypeImpl("tasksList", + VCloudMediaType.TASKSLIST_XML, URI.create("https://vcenterprise.bluelock.com/api/v1.0/tasksList/1")); + + protected static final ReferenceTypeImpl VDC_REF = new ReferenceTypeImpl("vdc", VCloudMediaType.VDC_XML, + URI.create("https://vcenterprise.bluelock.com/api/v1.0/vdc/1")); + + protected static final ReferenceTypeImpl NETWORK_REF = new ReferenceTypeImpl("network", VCloudMediaType.NETWORK_XML, + URI.create("https://vcloud.safesecureweb.com/network/1990")); + + protected static final Org ORG = new OrgImpl(ORG_REF.getName(), ORG_REF.getType(), ORG_REF.getHref(), "org", null, + ImmutableMap. of(CATALOG_REF.getName(), CATALOG_REF), + ImmutableMap. of(VDC_REF.getName(), VDC_REF), ImmutableMap. of( + NETWORK_REF.getName(), NETWORK_REF), TASKSLIST_REF, ImmutableList. of()); + + protected static final VDC VDC = new VDCImpl(VDC_REF.getName(), VDC_REF.getType(), VDC_REF.getHref(), + VDCStatus.READY, null, "description", ImmutableSet. of(), AllocationModel.ALLOCATION_POOL, null, null, + null, ImmutableMap. of( + "vapp", + new ReferenceTypeImpl("vapp", "application/vnd.vmware.vcloud.vApp+xml", URI + .create("https://vcenterprise.bluelock.com/api/v1.0/vApp/188849-1")), + "network", + new ReferenceTypeImpl("network", "application/vnd.vmware.vcloud.vAppTemplate+xml", URI + .create("https://vcenterprise.bluelock.com/api/v1.0/vdcItem/2"))), + ImmutableMap. of(NETWORK_REF.getName(), NETWORK_REF), 0, 0, 0, false); + @RequiresHttp @ConfiguresRestClient public static class VCloudRestClientModuleExtension extends VCloudRestClientModule { + @Override - protected URI provideAuthenticationURI(VCloudVersionsAsyncClient versionService, - @Named(PROPERTY_API_VERSION) String version) { + protected URI provideAuthenticationURI(VCloudVersionsAsyncClient versionService, String version) { return URI.create("https://vcenterprise.bluelock.com/api/v1.0/login"); } @Override - protected URI provideOrg(@org.jclouds.vcloud.endpoints.Org Iterable orgs) { - return URI.create("https://vcenterprise.bluelock.com/api/v1.0/org"); - + protected Org provideOrg(Supplier> orgSupplier, + @org.jclouds.vcloud.endpoints.Org ReferenceType defaultOrg) { + return ORG; } @Override - protected String provideOrgName(@org.jclouds.vcloud.endpoints.Org Iterable orgs) { - return "org"; - } + protected void installDefaultVCloudEndpointsModule() { + install(new AbstractModule() { - @Override - protected URI provideCatalog(Org org, @Named(PROPERTY_IDENTITY) String user, WriteableCatalog writableCatalog) { - return URI.create("https://vcenterprise.bluelock.com/api/v1.0/catalog"); + @Override + protected void configure() { + bind(ReferenceType.class).annotatedWith(org.jclouds.vcloud.endpoints.Org.class).toInstance(ORG_REF); + bind(ReferenceType.class).annotatedWith(org.jclouds.vcloud.endpoints.Catalog.class).toInstance( + CATALOG_REF); + bind(ReferenceType.class).annotatedWith(org.jclouds.vcloud.endpoints.TasksList.class).toInstance( + TASKSLIST_REF); + bind(ReferenceType.class).annotatedWith(org.jclouds.vcloud.endpoints.VDC.class).toInstance(VDC_REF); + bind(ReferenceType.class).annotatedWith(org.jclouds.vcloud.endpoints.Network.class).toInstance( + NETWORK_REF); + } - } - - @Override - protected Org provideOrg(CommonVCloudClient discovery) { - return null; - } - - @Override - protected URI provideDefaultTasksList(Org org) { - return URI.create("https://vcenterprise.bluelock.com/api/v1.0/taskslist"); - } - - @Override - protected URI provideDefaultVDC(Org org, @org.jclouds.vcloud.endpoints.VDC String defaultVDC) { - return URI.create("https://vcenterprise.bluelock.com/api/v1.0/vdc/1"); - } - - @Override - protected String provideDefaultVDCName( - @org.jclouds.vcloud.endpoints.VDC Supplier> vDCtoOrgSupplier) { - return "vdc"; - } - - @Override - protected URI provideDefaultNetwork(URI vdc, Injector injector) { - return URI.create("https://vcenterprise.bluelock.com/api/v1.0/network/1990"); + }); } @Override protected Supplier provideVCloudTokenCache(@Named(PROPERTY_SESSION_INTERVAL) long seconds, - final VCloudLoginAsyncClient login) { + AtomicReference authException, final VCloudLoginAsyncClient login) { return Suppliers. ofInstance(new VCloudSession() { @Override public Map getOrgs() { - return ImmutableMap. of("org", new ReferenceTypeImpl("org", - VCloudMediaType.ORG_XML, URI.create("https://vcenterprise.bluelock.com/api/v1.0/org/1"))); + return ImmutableMap. of(ORG_REF.getName(), ORG_REF); } @Override @@ -168,51 +181,18 @@ public abstract class BaseVCloudAsyncClientTest extends RestClientTest { bind(OrgCatalogItemSupplier.class).to(TestOrgCatalogItemSupplier.class); } + @Override protected Supplier>> provideOrgVDCSupplierCache( - @Named(PROPERTY_SESSION_INTERVAL) long seconds, final OrgVDCSupplier supplier) { - - return Suppliers - .>> ofInstance(ImmutableMap - .> of( - "org", - - ImmutableMap - . of( - "vdc", - new VDCImpl( - "vdc", - null, - URI - .create("https://vcenterprise.bluelock.com/api/v1.0/vdc/1"), - VDCStatus.READY, - null, - "description", - ImmutableSet. of(), - AllocationModel.ALLOCATION_POOL, - null, - null, - null, - ImmutableMap - . of( - "vapp", - new ReferenceTypeImpl( - "vapp", - "application/vnd.vmware.vcloud.vApp+xml", - URI - .create("https://vcenterprise.bluelock.com/api/v1.0/vApp/188849-1")), - "network", - new ReferenceTypeImpl( - "network", - "application/vnd.vmware.vcloud.vAppTemplate+xml", - URI - .create("https://vcenterprise.bluelock.com/api/v1.0/vdcItem/2"))), - ImmutableMap. of(), 0, 0, 0, - false)))); - + @Named(PROPERTY_SESSION_INTERVAL) long seconds, AtomicReference authException, + OrgVDCSupplier supplier) { + return Suppliers.>> ofInstance(ImmutableMap + .> of(ORG_REF.getName(), + ImmutableMap. of(VDC.getName(), VDC))); } @Singleton public static class TestOrgMapSupplier extends OrgMapSupplier { + @Inject protected TestOrgMapSupplier() { super(null, null); @@ -220,19 +200,7 @@ public abstract class BaseVCloudAsyncClientTest extends RestClientTest { @Override public Map get() { - return ImmutableMap. of("org", new OrgImpl("org", null, URI - .create("https://vcenterprise.bluelock.com/api/v1.0/org/1"), "org", "description", ImmutableMap - . of("catalog", new ReferenceTypeImpl("catalog", - VCloudMediaType.CATALOG_XML, URI - .create("https://vcenterprise.bluelock.com/api/v1.0/catalog/1"))), ImmutableMap - . of("vdc", new ReferenceTypeImpl("vdc", VCloudMediaType.VDC_XML, URI - .create("https://vcenterprise.bluelock.com/api/v1.0/vdc/1"))), ImmutableMap - . of("network", new ReferenceTypeImpl("network", - VCloudMediaType.NETWORK_XML, URI - .create("https://vcenterprise.bluelock.com/api/v1.0/network/1"))), - new ReferenceTypeImpl("tasksList", VCloudMediaType.TASKSLIST_XML, URI - .create("https://vcenterprise.bluelock.com/api/v1.0/tasksList/1")), ImmutableList - . of())); + return ImmutableMap. of(ORG.getName(), ORG); } } @@ -245,17 +213,18 @@ public abstract class BaseVCloudAsyncClientTest extends RestClientTest { @Override public Map> get() { - return ImmutableMap.> of("org", - - ImmutableMap. of("catalog", new CatalogImpl("catalog", "type", - URI.create("https://vcenterprise.bluelock.com/api/v1.0/catalog/1"), null, "description", - ImmutableMap. of("item", new ReferenceTypeImpl("item", - "application/vnd.vmware.vcloud.catalogItem+xml", URI - .create("https://vcenterprise.bluelock.com/api/v1.0/catalogItem/1")), - "template", new ReferenceTypeImpl("template", - "application/vnd.vmware.vcloud.vAppTemplate+xml", URI - .create("https://vcenterprise.bluelock.com/api/v1.0/catalogItem/2"))), - ImmutableList. of(), true, false))); + return ImmutableMap.> of( + ORG_REF.getName(), ImmutableMap. of( + CATALOG_REF.getName(), + new CatalogImpl(CATALOG_REF.getName(), CATALOG_REF.getType(), CATALOG_REF.getHref(), null, + "description", ImmutableMap. of( + "item", + new ReferenceTypeImpl("item", "application/vnd.vmware.vcloud.catalogItem+xml", URI + .create("https://vcenterprise.bluelock.com/api/v1.0/catalogItem/1")), + "template", + new ReferenceTypeImpl("template", "application/vnd.vmware.vcloud.vAppTemplate+xml", + URI.create("https://vcenterprise.bluelock.com/api/v1.0/catalogItem/2"))), + ImmutableList. of(), true, false))); } } @@ -267,35 +236,20 @@ public abstract class BaseVCloudAsyncClientTest extends RestClientTest { @Override public Map>> get() { - return ImmutableMap - .>> of( - "org", - ImmutableMap - .> of( - "catalog", - ImmutableMap - . of( - "template", - new CatalogItemImpl( - "template", - URI - .create("https://vcenterprise.bluelock.com/api/v1.0/catalogItem/2"), - "description", - new ReferenceTypeImpl( - "template", - "application/vnd.vmware.vcloud.vAppTemplate+xml", - URI - .create("https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/2")), - ImmutableMap. of())))); + return ImmutableMap.>> of( + ORG_REF.getName(), ImmutableMap + .> of(CATALOG_REF + .getName(), ImmutableMap. of( + "template", + new CatalogItemImpl("template", URI + .create("https://vcenterprise.bluelock.com/api/v1.0/catalogItem/2"), "description", + new ReferenceTypeImpl("template", "application/vnd.vmware.vcloud.vAppTemplate+xml", + URI.create("https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/2")), + ImmutableMap. of())))); } } - @Override - protected Iterable provideOrgs(Supplier cache, String user) { - return null; - } - } } diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/DeprecatedVCloudClientLiveTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/DeprecatedVCloudClientLiveTest.java index 7dfa80af75..244142dfed 100644 --- a/apis/vcloud/src/test/java/org/jclouds/vcloud/DeprecatedVCloudClientLiveTest.java +++ b/apis/vcloud/src/test/java/org/jclouds/vcloud/DeprecatedVCloudClientLiveTest.java @@ -31,6 +31,9 @@ import org.jclouds.vcloud.domain.VDC; import org.jclouds.vcloud.domain.Vm; import org.testng.annotations.Test; +import com.google.common.base.Function; +import com.google.common.collect.Iterables; + /** * Tests behavior of deprecated {@code VCloudClient} features * @@ -40,30 +43,43 @@ import org.testng.annotations.Test; @Test(groups = "live", singleThreaded = true) public class DeprecatedVCloudClientLiveTest extends CommonVCloudClientLiveTest { + @Override + protected Iterable listOrgs() { + return Iterables.transform(connection.listOrgs().values(), new Function(){ + + @Override + public Org apply(ReferenceType arg0) { + return connection.getOrg(arg0.getHref()); + } + + }); + } + @Test public void testListOrgs() throws Exception { - for (ReferenceType response : connection.listOrgs().values()) { - assertNotNull(response); - assertNotNull(response.getName()); - assertNotNull(response.getHref()); - assertEquals(connection.getOrg(response.getHref()).getName(), response.getName()); - assertEquals(connection.findOrgNamed(response.getName()).getName(), response.getName()); + for (Org org : orgs) { + assertNotNull(org); + assertNotNull(org.getName()); + assertNotNull(org.getHref()); + assertEquals(connection.getOrg(org.getHref()).getName(), org.getName()); + assertEquals(connection.findOrgNamed(org.getName()).getName(), org.getName()); } } @Test public void testGetVAppTemplate() throws Exception { - Org org = connection.findOrgNamed(null); - for (ReferenceType cat : org.getCatalogs().values()) { - Catalog response = connection.getCatalog(cat.getHref()); - for (ReferenceType resource : response.values()) { - if (resource.getType().equals(VCloudMediaType.CATALOGITEM_XML)) { - CatalogItem item = connection.getCatalogItem(resource.getHref()); - if (item.getEntity().getType().equals(VCloudMediaType.VAPPTEMPLATE_XML)) { - try { - assertNotNull(connection.getVAppTemplate(item.getEntity().getHref())); - } catch (AuthorizationException e) { + for (Org org : orgs) { + for (ReferenceType cat : org.getCatalogs().values()) { + Catalog response = connection.getCatalog(cat.getHref()); + for (ReferenceType resource : response.values()) { + if (resource.getType().equals(VCloudMediaType.CATALOGITEM_XML)) { + CatalogItem item = connection.getCatalogItem(resource.getHref()); + if (item.getEntity().getType().equals(VCloudMediaType.VAPPTEMPLATE_XML)) { + try { + assertNotNull(connection.getVAppTemplate(item.getEntity().getHref())); + } catch (AuthorizationException e) { + } } } } @@ -73,96 +89,16 @@ public class DeprecatedVCloudClientLiveTest extends CommonVCloudClientLiveTest 0; + } catch (RuntimeException e) { + + } + } + } + } + } + } + + @Test + public void testFindVAppTemplate() throws Exception { + for (Org org : orgs) { + for (ReferenceType cat : org.getCatalogs().values()) { + Catalog response = connection.getCatalog(cat.getHref()); + for (ReferenceType resource : response.values()) { + if (resource.getType().equals(VCloudMediaType.CATALOGITEM_XML)) { + CatalogItem item = connection.getCatalogItem(resource.getHref()); + if (item.getEntity().getType().equals(VCloudMediaType.VAPPTEMPLATE_XML)) { + try { + assertNotNull(connection.findVAppTemplateInOrgCatalogNamed(org.getName(), response.getName(), + item.getEntity().getName())); + } catch (AuthorizationException e) { + + } + } + } + } + } + } + } + } diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/binders/BindInstantiateVAppTemplateParamsToXmlPayloadTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/binders/BindInstantiateVAppTemplateParamsToXmlPayloadTest.java index 2439d1e8b0..3ffe80a54e 100644 --- a/apis/vcloud/src/test/java/org/jclouds/vcloud/binders/BindInstantiateVAppTemplateParamsToXmlPayloadTest.java +++ b/apis/vcloud/src/test/java/org/jclouds/vcloud/binders/BindInstantiateVAppTemplateParamsToXmlPayloadTest.java @@ -37,7 +37,9 @@ import org.jclouds.rest.internal.GeneratedHttpRequest; import org.jclouds.util.Strings2; import org.jclouds.vcloud.VCloudClient; import org.jclouds.vcloud.VCloudPropertiesBuilder; +import org.jclouds.vcloud.domain.ReferenceType; import org.jclouds.vcloud.domain.VAppTemplate; +import org.jclouds.vcloud.domain.internal.ReferenceTypeImpl; import org.jclouds.vcloud.domain.network.FenceMode; import org.jclouds.vcloud.domain.network.NetworkConfig; import org.jclouds.vcloud.domain.ovf.VCloudNetworkSection; @@ -84,8 +86,8 @@ public class BindInstantiateVAppTemplateParamsToXmlPayloadTest { @Network @Provides @Singleton - URI provideNetwork() { - return URI.create("https://vcenterprise.bluelock.com/api/v1.0/network/1990"); + ReferenceType provideNetwork() { + return new ReferenceTypeImpl(null, null, URI.create("https://vcenterprise.bluelock.com/api/v1.0/network/1990")); } }); } diff --git a/apis/vcloudexpress/src/main/java/org/jclouds/vcloud/VCloudExpressAsyncClient.java b/apis/vcloudexpress/src/main/java/org/jclouds/vcloud/VCloudExpressAsyncClient.java index bbe3120007..db0c85f0b9 100644 --- a/apis/vcloudexpress/src/main/java/org/jclouds/vcloud/VCloudExpressAsyncClient.java +++ b/apis/vcloudexpress/src/main/java/org/jclouds/vcloud/VCloudExpressAsyncClient.java @@ -25,6 +25,7 @@ import static org.jclouds.vcloud.VCloudMediaType.VAPPTEMPLATE_XML; import static org.jclouds.vcloud.VCloudMediaType.VAPP_XML; import java.net.URI; +import java.util.Map; import javax.annotation.Nullable; import javax.ws.rs.Consumes; @@ -47,10 +48,12 @@ import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404; import org.jclouds.vcloud.binders.BindCloneVCloudExpressVAppParamsToXmlPayload; import org.jclouds.vcloud.binders.BindInstantiateVCloudExpressVAppTemplateParamsToXmlPayload; import org.jclouds.vcloud.domain.Catalog; +import org.jclouds.vcloud.domain.ReferenceType; import org.jclouds.vcloud.domain.Task; import org.jclouds.vcloud.domain.VCloudExpressVApp; import org.jclouds.vcloud.domain.VCloudExpressVAppTemplate; import org.jclouds.vcloud.domain.network.OrgNetwork; +import org.jclouds.vcloud.endpoints.Org; import org.jclouds.vcloud.filters.SetVCloudTokenCookie; import org.jclouds.vcloud.functions.OrgNameAndCatalogNameToEndpoint; import org.jclouds.vcloud.functions.OrgNameCatalogNameVAppTemplateNameToEndpoint; @@ -65,6 +68,7 @@ import org.jclouds.vcloud.xml.VCloudExpressVAppHandler; import org.jclouds.vcloud.xml.VCloudExpressVAppTemplateHandler; import com.google.common.util.concurrent.ListenableFuture; +import com.google.inject.Provides; /** * Provides access to VCloud resources via their REST API. @@ -75,7 +79,14 @@ import com.google.common.util.concurrent.ListenableFuture; */ @RequestFilters(SetVCloudTokenCookie.class) public interface VCloudExpressAsyncClient extends CommonVCloudAsyncClient { - + /** + * + * @return a listing of all orgs that the current user has access to. + */ + @Provides + @Org + Map listOrgs(); + /** * @see CommonVCloudClient#getCatalog */ diff --git a/apis/vcloudexpress/src/main/java/org/jclouds/vcloud/VCloudExpressClient.java b/apis/vcloudexpress/src/main/java/org/jclouds/vcloud/VCloudExpressClient.java index 8c4138f5c8..791a8c270a 100644 --- a/apis/vcloudexpress/src/main/java/org/jclouds/vcloud/VCloudExpressClient.java +++ b/apis/vcloudexpress/src/main/java/org/jclouds/vcloud/VCloudExpressClient.java @@ -19,12 +19,14 @@ package org.jclouds.vcloud; import java.net.URI; +import java.util.Map; import java.util.NoSuchElementException; import java.util.concurrent.TimeUnit; import javax.annotation.Nullable; import org.jclouds.concurrent.Timeout; +import org.jclouds.vcloud.domain.ReferenceType; import org.jclouds.vcloud.domain.Task; import org.jclouds.vcloud.domain.VCloudExpressVApp; import org.jclouds.vcloud.domain.VCloudExpressVAppTemplate; @@ -40,7 +42,12 @@ import org.jclouds.vcloud.options.InstantiateVAppTemplateOptions; */ @Timeout(duration = 300, timeUnit = TimeUnit.SECONDS) public interface VCloudExpressClient extends CommonVCloudClient { - + /** + * + * @return a listing of all orgs that the current user has access to. + */ + Map listOrgs(); + VCloudExpressVApp instantiateVAppTemplateInVDC(URI vDC, URI template, String appName, InstantiateVAppTemplateOptions... options); diff --git a/apis/vcloudexpress/src/main/java/org/jclouds/vcloud/binders/BindInstantiateVCloudExpressVAppTemplateParamsToXmlPayload.java b/apis/vcloudexpress/src/main/java/org/jclouds/vcloud/binders/BindInstantiateVCloudExpressVAppTemplateParamsToXmlPayload.java index 2d41bcd355..738fa77d91 100644 --- a/apis/vcloudexpress/src/main/java/org/jclouds/vcloud/binders/BindInstantiateVCloudExpressVAppTemplateParamsToXmlPayload.java +++ b/apis/vcloudexpress/src/main/java/org/jclouds/vcloud/binders/BindInstantiateVCloudExpressVAppTemplateParamsToXmlPayload.java @@ -44,6 +44,7 @@ import org.jclouds.http.HttpRequest; import org.jclouds.rest.MapBinder; import org.jclouds.rest.binders.BindToStringPayload; import org.jclouds.rest.internal.GeneratedHttpRequest; +import org.jclouds.vcloud.domain.ReferenceType; import org.jclouds.vcloud.domain.network.NetworkConfig; import org.jclouds.vcloud.endpoints.Network; import org.jclouds.vcloud.options.InstantiateVAppTemplateOptions; @@ -67,14 +68,14 @@ public class BindInstantiateVCloudExpressVAppTemplateParamsToXmlPayload implemen private final BindToStringPayload stringBinder; protected final Map virtualHardwareToInstanceId = ImmutableMap.of(ResourceType.PROCESSOR, "1", ResourceType.MEMORY, "2", ResourceType.DISK_DRIVE, "9"); - private final URI defaultNetwork; + private final ReferenceType defaultNetwork; private final String defaultFenceMode; private final String apiVersion; @Inject public BindInstantiateVCloudExpressVAppTemplateParamsToXmlPayload(BindToStringPayload stringBinder, @Named(PROPERTY_API_VERSION) String apiVersion, @Named(PROPERTY_VCLOUD_XML_NAMESPACE) String ns, - @Named(PROPERTY_VCLOUD_XML_SCHEMA) String schema, @Network URI network, + @Named(PROPERTY_VCLOUD_XML_SCHEMA) String schema, @Network ReferenceType network, @Named(PROPERTY_VCLOUD_DEFAULT_FENCEMODE) String fenceMode) { this.ns = ns; this.apiVersion = apiVersion; @@ -96,7 +97,7 @@ public class BindInstantiateVCloudExpressVAppTemplateParamsToXmlPayload implemen SortedMap virtualHardwareQuantity = Maps.newTreeMap(); InstantiateVAppTemplateOptions options = findOptionsInArgsOrNull(gRequest); - String network = (defaultNetwork != null) ? defaultNetwork.toASCIIString() : null; + String network = (defaultNetwork != null) ? defaultNetwork.getHref().toASCIIString() : null; String fenceMode = defaultFenceMode; String networkName = name; if (options != null) { diff --git a/apis/vcloudexpress/src/main/java/org/jclouds/vcloud/compute/functions/VCloudExpressVAppToNodeMetadata.java b/apis/vcloudexpress/src/main/java/org/jclouds/vcloud/compute/functions/VCloudExpressVAppToNodeMetadata.java index a5fafd2a77..3da4e684cf 100644 --- a/apis/vcloudexpress/src/main/java/org/jclouds/vcloud/compute/functions/VCloudExpressVAppToNodeMetadata.java +++ b/apis/vcloudexpress/src/main/java/org/jclouds/vcloud/compute/functions/VCloudExpressVAppToNodeMetadata.java @@ -34,6 +34,8 @@ import org.jclouds.compute.domain.Image; import org.jclouds.compute.domain.NodeMetadata; import org.jclouds.compute.domain.NodeMetadataBuilder; import org.jclouds.compute.domain.NodeState; +import org.jclouds.compute.domain.OperatingSystem; +import org.jclouds.compute.util.ComputeServiceUtils; import org.jclouds.domain.Credentials; import org.jclouds.vcloud.compute.VCloudExpressComputeClient; import org.jclouds.vcloud.domain.Status; @@ -57,9 +59,9 @@ public class VCloudExpressVAppToNodeMetadata implements Function credentialStore, Map vAppStatusToNodeState, - HardwareForVCloudExpressVApp hardwareForVCloudExpressVApp, - FindLocationForResource findLocationForResourceInVDC, @Memoized Supplier> images) { + Map credentialStore, Map vAppStatusToNodeState, + HardwareForVCloudExpressVApp hardwareForVCloudExpressVApp, + FindLocationForResource findLocationForResourceInVDC, @Memoized Supplier> images) { this.images = checkNotNull(images, "images"); this.hardwareForVCloudExpressVApp = checkNotNull(hardwareForVCloudExpressVApp, "hardwareForVCloudExpressVApp"); this.findLocationForResourceInVDC = checkNotNull(findLocationForResourceInVDC, "findLocationForResourceInVDC"); @@ -76,8 +78,19 @@ public class VCloudExpressVAppToNodeMetadata implements Function syncClientType, Class asyncClientType) { super(syncClientType, asyncClientType); } - + + /** + * + * @return a listing of all orgs that the current user has access to. + */ + @Provides + @Org + Map listOrgs(Supplier sessionSupplier) { + return sessionSupplier.get().getOrgs(); + } + public BaseVCloudExpressRestClientModule(Class syncClientType, Class asyncClientType, Map, Class> delegateMap) { super(syncClientType, asyncClientType, delegateMap); @@ -81,7 +95,7 @@ public abstract class BaseVCloudExpressRestClientModule provideVCloudTokenCache(@Named(PROPERTY_SESSION_INTERVAL) long seconds, - final VCloudExpressLoginAsyncClient login) { + AtomicReference authException, final VCloudExpressLoginAsyncClient login) { return new MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier(authException, seconds, new Supplier() { diff --git a/apis/vcloudexpress/src/main/java/org/jclouds/vcloud/domain/internal/VCloudExpressVAppImpl.java b/apis/vcloudexpress/src/main/java/org/jclouds/vcloud/domain/internal/VCloudExpressVAppImpl.java index 4e4a7c6b7f..3f8cf7d710 100644 --- a/apis/vcloudexpress/src/main/java/org/jclouds/vcloud/domain/internal/VCloudExpressVAppImpl.java +++ b/apis/vcloudexpress/src/main/java/org/jclouds/vcloud/domain/internal/VCloudExpressVAppImpl.java @@ -51,9 +51,6 @@ public class VCloudExpressVAppImpl implements VCloudExpressVApp { private final Set resourceAllocations; private final Integer osType; - /** The serialVersionUID */ - private static final long serialVersionUID = 8464716396538298809L; - public VCloudExpressVAppImpl(String name, URI href, Status status, Long size, ReferenceType vDC, ListMultimap networkToAddresses, Integer osType, String operatingSystemDescription, VirtualSystemSettingData system, Set resourceAllocations) { diff --git a/apis/vcloudexpress/src/main/java/org/jclouds/vcloud/domain/internal/VCloudExpressVAppTemplateImpl.java b/apis/vcloudexpress/src/main/java/org/jclouds/vcloud/domain/internal/VCloudExpressVAppTemplateImpl.java index 6dad775bd8..9722c6d356 100644 --- a/apis/vcloudexpress/src/main/java/org/jclouds/vcloud/domain/internal/VCloudExpressVAppTemplateImpl.java +++ b/apis/vcloudexpress/src/main/java/org/jclouds/vcloud/domain/internal/VCloudExpressVAppTemplateImpl.java @@ -33,8 +33,6 @@ import org.jclouds.vcloud.domain.VCloudExpressVAppTemplate; */ public class VCloudExpressVAppTemplateImpl extends ReferenceTypeImpl implements VCloudExpressVAppTemplate { - /** The serialVersionUID */ - private static final long serialVersionUID = 8464716396538298809L; private final String description; private final Status status; diff --git a/apis/vcloudexpress/src/main/java/org/jclouds/vcloud/domain/network/internal/VCloudExpressNetworkImpl.java b/apis/vcloudexpress/src/main/java/org/jclouds/vcloud/domain/network/internal/VCloudExpressNetworkImpl.java index 8f18e6f5c2..9491527e3a 100644 --- a/apis/vcloudexpress/src/main/java/org/jclouds/vcloud/domain/network/internal/VCloudExpressNetworkImpl.java +++ b/apis/vcloudexpress/src/main/java/org/jclouds/vcloud/domain/network/internal/VCloudExpressNetworkImpl.java @@ -40,8 +40,6 @@ import com.google.common.collect.Sets; */ public class VCloudExpressNetworkImpl extends ReferenceTypeImpl implements VCloudExpressNetwork { - /** The serialVersionUID */ - private static final long serialVersionUID = 8464716396538298809L; protected final String description; protected final Set dnsServers = Sets.newHashSet(); protected final String gateway; diff --git a/apis/vcloudexpress/src/test/java/org/jclouds/vcloud/VCloudExpressAsyncClientTest.java b/apis/vcloudexpress/src/test/java/org/jclouds/vcloud/VCloudExpressAsyncClientTest.java index cbdcff315a..df279cfd56 100644 --- a/apis/vcloudexpress/src/test/java/org/jclouds/vcloud/VCloudExpressAsyncClientTest.java +++ b/apis/vcloudexpress/src/test/java/org/jclouds/vcloud/VCloudExpressAsyncClientTest.java @@ -18,8 +18,6 @@ */ package org.jclouds.vcloud; -import static org.jclouds.Constants.PROPERTY_API_VERSION; -import static org.jclouds.Constants.PROPERTY_IDENTITY; import static org.jclouds.Constants.PROPERTY_SESSION_INTERVAL; import static org.jclouds.vcloud.options.InstantiateVAppTemplateOptions.Builder.processorCount; import static org.testng.Assert.assertEquals; @@ -30,6 +28,7 @@ import java.net.URI; import java.util.Map; import java.util.NoSuchElementException; import java.util.Properties; +import java.util.concurrent.atomic.AtomicReference; import javax.inject.Inject; import javax.inject.Named; @@ -39,6 +38,7 @@ import org.jclouds.http.HttpRequest; import org.jclouds.http.RequiresHttp; import org.jclouds.http.functions.ParseSax; import org.jclouds.http.functions.ReleasePayloadAndReturn; +import org.jclouds.rest.AuthorizationException; import org.jclouds.rest.ConfiguresRestClient; import org.jclouds.rest.RestClientTest; import org.jclouds.rest.RestContextFactory; @@ -47,10 +47,13 @@ import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404; import org.jclouds.rest.internal.RestAnnotationProcessor; import org.jclouds.util.Strings2; import org.jclouds.vcloud.config.VCloudExpressRestClientModule; +import org.jclouds.vcloud.domain.AllocationModel; import org.jclouds.vcloud.domain.Org; import org.jclouds.vcloud.domain.ReferenceType; import org.jclouds.vcloud.domain.Task; import org.jclouds.vcloud.domain.VCloudSession; +import org.jclouds.vcloud.domain.VDC; +import org.jclouds.vcloud.domain.VDCStatus; import org.jclouds.vcloud.domain.internal.CatalogImpl; import org.jclouds.vcloud.domain.internal.CatalogItemImpl; import org.jclouds.vcloud.domain.internal.OrgImpl; @@ -62,12 +65,12 @@ import org.jclouds.vcloud.filters.SetVCloudTokenCookie; import org.jclouds.vcloud.functions.ParseTaskFromLocationHeader; import org.jclouds.vcloud.options.CloneVAppOptions; import org.jclouds.vcloud.options.InstantiateVAppTemplateOptions; -import org.jclouds.vcloud.xml.VCloudExpressCatalogHandler; import org.jclouds.vcloud.xml.CatalogItemHandler; import org.jclouds.vcloud.xml.OrgHandler; import org.jclouds.vcloud.xml.OrgNetworkFromVCloudExpressNetworkHandler; import org.jclouds.vcloud.xml.TaskHandler; import org.jclouds.vcloud.xml.TasksListHandler; +import org.jclouds.vcloud.xml.VCloudExpressCatalogHandler; import org.jclouds.vcloud.xml.VCloudExpressVAppHandler; import org.jclouds.vcloud.xml.VCloudExpressVAppTemplateHandler; import org.jclouds.vcloud.xml.VDCHandler; @@ -77,7 +80,8 @@ import com.google.common.base.Supplier; import com.google.common.base.Suppliers; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; -import com.google.inject.Injector; +import com.google.common.collect.ImmutableSet; +import com.google.inject.AbstractModule; import com.google.inject.Module; import com.google.inject.TypeLiteral; @@ -86,10 +90,16 @@ import com.google.inject.TypeLiteral; * * @author Adrian Cole */ -// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire +// NOTE:without testName, this will not call @Before* and fail w/NPE during +// surefire @Test(groups = "unit", testName = "VCloudExpressAsyncClientTest") public class VCloudExpressAsyncClientTest extends RestClientTest { + public void testListOrgs() { + assertEquals(injector.getInstance(VCloudExpressAsyncClient.class).listOrgs().toString(), + ImmutableMap.of(ORG_REF.getName(), ORG_REF).toString()); + } + public void testInstantiateVAppTemplateInVDCURI() throws SecurityException, NoSuchMethodException, IOException { Method method = VCloudExpressAsyncClient.class.getMethod("instantiateVAppTemplateInVDC", URI.class, URI.class, String.class, InstantiateVAppTemplateOptions[].class); @@ -322,7 +332,22 @@ public class VCloudExpressAsyncClientTest extends RestClientTest of(CATALOG_REF.getName(), CATALOG_REF), + ImmutableMap. of(VDC_REF.getName(), VDC_REF), ImmutableMap. of( + NETWORK_REF.getName(), NETWORK_REF), TASKSLIST_REF, ImmutableList. of()); + + protected static final VDC VDC = new VDCImpl(VDC_REF.getName(), VDC_REF.getType(), VDC_REF.getHref(), + VDCStatus.READY, null, "description", ImmutableSet. of(), AllocationModel.ALLOCATION_POOL, null, null, + null, ImmutableMap. of( + "vapp", + new ReferenceTypeImpl("vapp", "application/vnd.vmware.vcloud.vApp+xml", URI + .create("https://vcloud.safesecureweb.com/api/v0.8/vApp/188849-1")), + "network", + new ReferenceTypeImpl("network", "application/vnd.vmware.vcloud.vAppTemplate+xml", URI + .create("https://vcloud.safesecureweb.com/api/v0.8/vdcItem/2"))), + ImmutableMap. of(NETWORK_REF.getName(), NETWORK_REF), 0, 0, 0, false); + @RequiresHttp @ConfiguresRestClient public static class VCloudRestClientModuleExtension extends VCloudExpressRestClientModule { + @Override - protected URI provideAuthenticationURI(VCloudVersionsAsyncClient versionService, - @Named(PROPERTY_API_VERSION) String version) { + protected URI provideAuthenticationURI(VCloudVersionsAsyncClient versionService, String version) { return URI.create("https://vcloud.safesecureweb.com/api/v0.8/login"); } @Override - protected URI provideOrg(@org.jclouds.vcloud.endpoints.Org Iterable orgs) { - return URI.create("https://vcloud.safesecureweb.com/api/v0.8/org"); - + protected Org provideOrg(Supplier> orgSupplier, + @org.jclouds.vcloud.endpoints.Org ReferenceType defaultOrg) { + return ORG; } @Override - protected String provideOrgName(@org.jclouds.vcloud.endpoints.Org Iterable orgs) { - return "org"; - } + protected void installDefaultVCloudEndpointsModule() { + install(new AbstractModule() { - @Override - protected URI provideCatalog(Org org, @Named(PROPERTY_IDENTITY) String user, WriteableCatalog write) { - return URI.create("https://vcloud.safesecureweb.com/api/v0.8/catalog"); - } + @Override + protected void configure() { + bind(ReferenceType.class).annotatedWith(org.jclouds.vcloud.endpoints.Org.class).toInstance(ORG_REF); + bind(ReferenceType.class).annotatedWith(org.jclouds.vcloud.endpoints.Catalog.class).toInstance( + CATALOG_REF); + bind(ReferenceType.class).annotatedWith(org.jclouds.vcloud.endpoints.TasksList.class).toInstance( + TASKSLIST_REF); + bind(ReferenceType.class).annotatedWith(org.jclouds.vcloud.endpoints.VDC.class).toInstance(VDC_REF); + bind(ReferenceType.class).annotatedWith(org.jclouds.vcloud.endpoints.Network.class).toInstance( + NETWORK_REF); + } - @Override - protected Org provideOrg(CommonVCloudClient discovery) { - return null; - } - - @Override - protected Iterable provideOrgs(Supplier cache, @Named(PROPERTY_IDENTITY) String user) { - return null; - } - - @Override - protected URI provideDefaultTasksList(Org org) { - return URI.create("https://vcloud.safesecureweb.com/api/v0.8/taskslist"); - } - - @Override - protected URI provideDefaultVDC(Org org, @org.jclouds.vcloud.endpoints.VDC String defaultVDC) { - return URI.create("https://vcloud.safesecureweb.com/api/v0.8/vdc/1"); - } - - @Override - protected String provideDefaultVDCName( - @org.jclouds.vcloud.endpoints.VDC Supplier> vDCtoOrgSupplier) { - return "vdc"; - } - - @Override - protected URI provideDefaultNetwork(URI vdc, Injector injector) { - return URI.create("https://vcloud.safesecureweb.com/network/1990"); + }); } @Override protected Supplier provideVCloudTokenCache(@Named(PROPERTY_SESSION_INTERVAL) long seconds, - final VCloudExpressLoginAsyncClient login) { + AtomicReference authException, VCloudExpressLoginAsyncClient login) { return Suppliers. ofInstance(new VCloudSession() { @Override public Map getOrgs() { - return ImmutableMap. of("org", new ReferenceTypeImpl("org", - VCloudExpressMediaType.ORG_XML, URI.create("https://vcloud.safesecureweb.com/api/v0.8/org/1"))); + return ImmutableMap. of(ORG_REF.getName(), ORG_REF); } @Override @@ -744,26 +777,14 @@ public class VCloudExpressAsyncClientTest extends RestClientTest>> provideOrgVDCSupplierCache( @Named(PROPERTY_SESSION_INTERVAL) long seconds, final OrgVDCSupplier supplier) { - return Suppliers.>> ofInstance(ImmutableMap - .> of("org", - - ImmutableMap. of( - "vdc", - new VDCImpl("vdc", null, URI.create("https://vcloud.safesecureweb.com/api/v0.8/vdc/1"), null, - null, "description", null, null, null, null, null, ImmutableMap. of( - "vapp", - new ReferenceTypeImpl("vapp", "application/vnd.vmware.vcloud.vApp+xml", URI - .create("https://vcloud.safesecureweb.com/api/v0.8/vApp/188849-1")), - "network", - new ReferenceTypeImpl("network", "application/vnd.vmware.vcloud.vAppTemplate+xml", URI - .create("https://vcloud.safesecureweb.com/api/v0.8/vdcItem/2"))), null, 0, 0, 0, - false)))); - + .> of(ORG_REF.getName(), + ImmutableMap. of(VDC.getName(), VDC))); } @Singleton public static class TestOrgMapSupplier extends OrgMapSupplier { + @Inject protected TestOrgMapSupplier() { super(null, null); @@ -771,21 +792,7 @@ public class VCloudExpressAsyncClientTest extends RestClientTest get() { - return ImmutableMap. of( - "org", - new OrgImpl("org", null, URI.create("https://vcloud.safesecureweb.com/api/v0.8/org/1"), "org", null, - ImmutableMap. of( - "catalog", - new ReferenceTypeImpl("catalog", VCloudExpressMediaType.CATALOG_XML, URI - .create("https://vcloud.safesecureweb.com/api/v0.8/catalog/1"))), ImmutableMap - . of( - "vdc", - new ReferenceTypeImpl("vdc", VCloudExpressMediaType.VDC_XML, URI - .create("https://vcloud.safesecureweb.com/api/v0.8/vdc/1"))), ImmutableMap - . of(), new ReferenceTypeImpl("tasksList", - VCloudExpressMediaType.TASKSLIST_XML, URI - .create("https://vcloud.safesecureweb.com/api/v0.8/tasksList/1")), ImmutableList - . of())); + return ImmutableMap. of(ORG.getName(), ORG); } } @@ -798,19 +805,18 @@ public class VCloudExpressAsyncClientTest extends RestClientTest> get() { - return ImmutableMap.> of("org", - - ImmutableMap. of( - "catalog", - new CatalogImpl("catalog", "type", URI.create("https://vcloud.safesecureweb.com/api/v0.8/catalog/1"), - null, "description", ImmutableMap. of( - "item", - new ReferenceTypeImpl("item", "application/vnd.vmware.vcloud.catalogItem+xml", URI - .create("https://vcloud.safesecureweb.com/api/v0.8/catalogItem/1")), - "template", - new ReferenceTypeImpl("template", "application/vnd.vmware.vcloud.vAppTemplate+xml", URI - .create("https://vcloud.safesecureweb.com/api/v0.8/catalogItem/2"))), ImmutableList - . of(), true, false))); + return ImmutableMap.> of( + ORG_REF.getName(), ImmutableMap. of( + CATALOG_REF.getName(), + new CatalogImpl(CATALOG_REF.getName(), CATALOG_REF.getType(), CATALOG_REF.getHref(), null, + "description", ImmutableMap. of( + "item", + new ReferenceTypeImpl("item", "application/vnd.vmware.vcloud.catalogItem+xml", URI + .create("https://vcloud.safesecureweb.com/api/v0.8/catalogItem/1")), + "template", + new ReferenceTypeImpl("template", "application/vnd.vmware.vcloud.vAppTemplate+xml", + URI.create("https://vcloud.safesecureweb.com/api/v0.8/catalogItem/2"))), + ImmutableList. of(), true, false))); } } @@ -823,8 +829,9 @@ public class VCloudExpressAsyncClientTest extends RestClientTest>> get() { return ImmutableMap.>> of( - "org", ImmutableMap.> of( - "catalog", ImmutableMap. of( + ORG_REF.getName(), ImmutableMap + .> of(CATALOG_REF + .getName(), ImmutableMap. of( "template", new CatalogItemImpl("template", URI .create("https://vcloud.safesecureweb.com/api/v0.8/catalogItem/2"), "description", diff --git a/apis/vcloudexpress/src/test/java/org/jclouds/vcloud/VCloudExpressClientLiveTest.java b/apis/vcloudexpress/src/test/java/org/jclouds/vcloud/VCloudExpressClientLiveTest.java index 1b39ffecf3..e60c169c3d 100644 --- a/apis/vcloudexpress/src/test/java/org/jclouds/vcloud/VCloudExpressClientLiveTest.java +++ b/apis/vcloudexpress/src/test/java/org/jclouds/vcloud/VCloudExpressClientLiveTest.java @@ -28,25 +28,41 @@ import org.jclouds.vcloud.domain.VCloudExpressVApp; import org.jclouds.vcloud.domain.VDC; import org.testng.annotations.Test; +import com.google.common.base.Function; +import com.google.common.collect.Iterables; + /** * Tests behavior of {@code VCloudExpressClient} * * @author Adrian Cole */ -@Test(groups = "live", sequential = true) +@Test(groups = "live", singleThreaded = true) public abstract class VCloudExpressClientLiveTest extends - CommonVCloudClientLiveTest { + CommonVCloudClientLiveTest { + @Override + protected Iterable listOrgs() { + return Iterables.transform(connection.listOrgs().values(), new Function(){ + + @Override + public Org apply(ReferenceType arg0) { + return connection.getOrg(arg0.getHref()); + } + + }); + } + @Test public void testGetVAppTemplate() throws Exception { - Org org = connection.findOrgNamed(null); - for (ReferenceType cat : org.getCatalogs().values()) { - Catalog response = connection.getCatalog(cat.getHref()); - for (ReferenceType resource : response.values()) { - if (resource.getType().equals(VCloudMediaType.CATALOGITEM_XML)) { - CatalogItem item = connection.getCatalogItem(resource.getHref()); - if (item.getEntity().getType().equals(VCloudMediaType.VAPPTEMPLATE_XML)) { - assertNotNull(connection.getVAppTemplate(item.getEntity().getHref())); + for (Org org : orgs) { + for (ReferenceType cat : org.getCatalogs().values()) { + Catalog response = connection.getCatalog(cat.getHref()); + for (ReferenceType resource : response.values()) { + if (resource.getType().equals(VCloudMediaType.CATALOGITEM_XML)) { + CatalogItem item = connection.getCatalogItem(resource.getHref()); + if (item.getEntity().getType().equals(VCloudMediaType.VAPPTEMPLATE_XML)) { + assertNotNull(connection.getVAppTemplate(item.getEntity().getHref())); + } } } } @@ -55,16 +71,17 @@ public abstract class VCloudExpressClientLiveTest extends @Test public void testGetVApp() throws Exception { - Org org = connection.findOrgNamed(null); - for (ReferenceType vdc : org.getVDCs().values()) { - VDC response = connection.getVDC(vdc.getHref()); - for (ReferenceType item : response.getResourceEntities().values()) { - if (item.getType().equals(VCloudMediaType.VAPP_XML)) { - try { - VCloudExpressVApp app = connection.getVApp(item.getHref()); - assertNotNull(app); - } catch (RuntimeException e) { + for (Org org : listOrgs()) { + for (ReferenceType vdc : org.getVDCs().values()) { + VDC response = connection.getVDC(vdc.getHref()); + for (ReferenceType item : response.getResourceEntities().values()) { + if (item.getType().equals(VCloudMediaType.VAPP_XML)) { + try { + VCloudExpressVApp app = connection.getVApp(item.getHref()); + assertNotNull(app); + } catch (RuntimeException e) { + } } } } @@ -73,15 +90,16 @@ public abstract class VCloudExpressClientLiveTest extends @Test public void testFindVAppTemplate() throws Exception { - Org org = connection.findOrgNamed(null); - for (ReferenceType cat : org.getCatalogs().values()) { - Catalog response = connection.getCatalog(cat.getHref()); - for (ReferenceType resource : response.values()) { - if (resource.getType().equals(VCloudMediaType.CATALOGITEM_XML)) { - CatalogItem item = connection.getCatalogItem(resource.getHref()); - if (item.getEntity().getType().equals(VCloudMediaType.VAPPTEMPLATE_XML)) { - assertNotNull(connection.findVAppTemplateInOrgCatalogNamed(org.getName(), response.getName(), item + for (Org org : listOrgs()) { + for (ReferenceType cat : org.getCatalogs().values()) { + Catalog response = connection.getCatalog(cat.getHref()); + for (ReferenceType resource : response.values()) { + if (resource.getType().equals(VCloudMediaType.CATALOGITEM_XML)) { + CatalogItem item = connection.getCatalogItem(resource.getHref()); + if (item.getEntity().getType().equals(VCloudMediaType.VAPPTEMPLATE_XML)) { + assertNotNull(connection.findVAppTemplateInOrgCatalogNamed(org.getName(), response.getName(), item .getEntity().getName())); + } } } } diff --git a/apis/vcloudexpress/src/test/java/org/jclouds/vcloud/binders/BindInstantiateVCloudExpressVAppTemplateParamsToXmlPayloadTest.java b/apis/vcloudexpress/src/test/java/org/jclouds/vcloud/binders/BindInstantiateVCloudExpressVAppTemplateParamsToXmlPayloadTest.java index 2c1e200eca..509afab294 100644 --- a/apis/vcloudexpress/src/test/java/org/jclouds/vcloud/binders/BindInstantiateVCloudExpressVAppTemplateParamsToXmlPayloadTest.java +++ b/apis/vcloudexpress/src/test/java/org/jclouds/vcloud/binders/BindInstantiateVCloudExpressVAppTemplateParamsToXmlPayloadTest.java @@ -34,6 +34,8 @@ import javax.inject.Singleton; import org.jclouds.rest.internal.GeneratedHttpRequest; import org.jclouds.util.Strings2; import org.jclouds.vcloud.VCloudExpressPropertiesBuilder; +import org.jclouds.vcloud.domain.ReferenceType; +import org.jclouds.vcloud.domain.internal.ReferenceTypeImpl; import org.jclouds.vcloud.domain.network.FenceMode; import org.jclouds.vcloud.endpoints.Network; import org.jclouds.vcloud.options.InstantiateVAppTemplateOptions; @@ -66,8 +68,8 @@ public class BindInstantiateVCloudExpressVAppTemplateParamsToXmlPayloadTest { @Network @Provides @Singleton - URI provideNetwork() { - return URI.create("https://vcloud.safesecureweb.com/network/1990"); + ReferenceType provideNetwork() { + return new ReferenceTypeImpl(null, null, URI.create("https://vcloud.safesecureweb.com/network/1990")); } }); diff --git a/common/trmk/src/main/java/org/jclouds/vcloud/terremark/TerremarkVCloudAsyncClient.java b/common/trmk/src/main/java/org/jclouds/vcloud/terremark/TerremarkVCloudAsyncClient.java index 56fbf30848..0a49720d7e 100644 --- a/common/trmk/src/main/java/org/jclouds/vcloud/terremark/TerremarkVCloudAsyncClient.java +++ b/common/trmk/src/main/java/org/jclouds/vcloud/terremark/TerremarkVCloudAsyncClient.java @@ -57,11 +57,9 @@ import org.jclouds.rest.functions.ReturnVoidOnNotFoundOr404; import org.jclouds.vcloud.VCloudExpressAsyncClient; import org.jclouds.vcloud.VCloudExpressClient; import org.jclouds.vcloud.domain.Catalog; -import org.jclouds.vcloud.domain.ReferenceType; import org.jclouds.vcloud.domain.Task; import org.jclouds.vcloud.domain.VCloudExpressVApp; import org.jclouds.vcloud.domain.VDC; -import org.jclouds.vcloud.endpoints.Org; import org.jclouds.vcloud.filters.SetVCloudTokenCookie; import org.jclouds.vcloud.functions.OrgNameAndVDCNameToEndpoint; import org.jclouds.vcloud.functions.OrgNameCatalogNameItemNameToEndpoint; @@ -98,7 +96,6 @@ import org.jclouds.vcloud.xml.VCloudExpressCatalogHandler; import org.jclouds.vcloud.xml.VCloudExpressVAppHandler; import com.google.common.util.concurrent.ListenableFuture; -import com.google.inject.Provides; /** * Provides access to VCloud resources via their REST API. @@ -109,13 +106,6 @@ import com.google.inject.Provides; */ @RequestFilters(SetVCloudTokenCookie.class) public interface TerremarkVCloudAsyncClient extends VCloudExpressAsyncClient { - /** - * - * @return a listing of all orgs that the current user has access to. - */ - @Provides - @Org - Iterable listOrgs(); /** * @see VCloudExpressClient#getCatalogItemInOrg diff --git a/common/trmk/src/main/java/org/jclouds/vcloud/terremark/TerremarkVCloudClient.java b/common/trmk/src/main/java/org/jclouds/vcloud/terremark/TerremarkVCloudClient.java index 68d377fc4c..fcdc4b3c37 100644 --- a/common/trmk/src/main/java/org/jclouds/vcloud/terremark/TerremarkVCloudClient.java +++ b/common/trmk/src/main/java/org/jclouds/vcloud/terremark/TerremarkVCloudClient.java @@ -26,10 +26,8 @@ import javax.annotation.Nullable; import org.jclouds.concurrent.Timeout; import org.jclouds.vcloud.VCloudExpressClient; -import org.jclouds.vcloud.domain.ReferenceType; import org.jclouds.vcloud.domain.Task; import org.jclouds.vcloud.domain.VCloudExpressVApp; -import org.jclouds.vcloud.endpoints.Org; import org.jclouds.vcloud.terremark.domain.CustomizationParameters; import org.jclouds.vcloud.terremark.domain.InternetService; import org.jclouds.vcloud.terremark.domain.KeyPair; @@ -43,8 +41,6 @@ import org.jclouds.vcloud.terremark.domain.VAppConfiguration; import org.jclouds.vcloud.terremark.options.AddInternetServiceOptions; import org.jclouds.vcloud.terremark.options.AddNodeOptions; -import com.google.inject.Provides; - /** * Provides access to VCloud resources via their REST API. *

    @@ -54,13 +50,6 @@ import com.google.inject.Provides; */ @Timeout(duration = 300, timeUnit = TimeUnit.SECONDS) public interface TerremarkVCloudClient extends VCloudExpressClient { - /** - * - * @return a listing of all orgs that the current user has access to. - */ - @Provides - @Org - Iterable listOrgs(); /** * {@inheritDoc} diff --git a/common/trmk/src/main/java/org/jclouds/vcloud/terremark/binders/TerremarkBindInstantiateVAppTemplateParamsToXmlPayload.java b/common/trmk/src/main/java/org/jclouds/vcloud/terremark/binders/TerremarkBindInstantiateVAppTemplateParamsToXmlPayload.java index 1acdb43069..bb827da44c 100644 --- a/common/trmk/src/main/java/org/jclouds/vcloud/terremark/binders/TerremarkBindInstantiateVAppTemplateParamsToXmlPayload.java +++ b/common/trmk/src/main/java/org/jclouds/vcloud/terremark/binders/TerremarkBindInstantiateVAppTemplateParamsToXmlPayload.java @@ -23,10 +23,9 @@ import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_DEFAU import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_XML_NAMESPACE; import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_XML_SCHEMA; -import java.net.URI; import java.util.Map; -import java.util.SortedMap; import java.util.Map.Entry; +import java.util.SortedMap; import javax.annotation.Nullable; import javax.inject.Inject; @@ -37,6 +36,7 @@ import org.jclouds.cim.ResourceAllocationSettingData.ResourceType; import org.jclouds.rest.binders.BindToStringPayload; import org.jclouds.rest.internal.GeneratedHttpRequest; import org.jclouds.vcloud.binders.BindInstantiateVCloudExpressVAppTemplateParamsToXmlPayload; +import org.jclouds.vcloud.domain.ReferenceType; import org.jclouds.vcloud.endpoints.Network; import org.jclouds.vcloud.options.InstantiateVAppTemplateOptions; import org.jclouds.vcloud.terremark.options.TerremarkInstantiateVAppTemplateOptions; @@ -55,7 +55,7 @@ public class TerremarkBindInstantiateVAppTemplateParamsToXmlPayload extends @Inject public TerremarkBindInstantiateVAppTemplateParamsToXmlPayload(BindToStringPayload stringBinder, @Named(PROPERTY_API_VERSION) String apiVersion, @Named(PROPERTY_VCLOUD_XML_NAMESPACE) String ns, - @Named(PROPERTY_VCLOUD_XML_SCHEMA) String schema, @Nullable @Network URI network, + @Named(PROPERTY_VCLOUD_XML_SCHEMA) String schema, @Nullable @Network ReferenceType network, @Named(PROPERTY_VCLOUD_DEFAULT_FENCEMODE) String fenceMode) { super(stringBinder, apiVersion, ns, schema, network, fenceMode); } diff --git a/common/trmk/src/main/java/org/jclouds/vcloud/terremark/config/TerremarkRestClientModule.java b/common/trmk/src/main/java/org/jclouds/vcloud/terremark/config/TerremarkRestClientModule.java index 6cfb44c4f7..23a5726d07 100644 --- a/common/trmk/src/main/java/org/jclouds/vcloud/terremark/config/TerremarkRestClientModule.java +++ b/common/trmk/src/main/java/org/jclouds/vcloud/terremark/config/TerremarkRestClientModule.java @@ -17,10 +17,12 @@ * ==================================================================== */ package org.jclouds.vcloud.terremark.config; + import static org.jclouds.Constants.PROPERTY_SESSION_INTERVAL; import java.io.IOException; import java.util.Map; +import java.util.concurrent.atomic.AtomicReference; import javax.inject.Inject; import javax.inject.Named; @@ -30,6 +32,7 @@ import org.jclouds.http.HttpErrorHandler; import org.jclouds.http.annotation.ClientError; import org.jclouds.http.annotation.Redirection; import org.jclouds.http.annotation.ServerError; +import org.jclouds.rest.AuthorizationException; import org.jclouds.rest.suppliers.MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier; import org.jclouds.util.Strings2; import org.jclouds.vcloud.config.BaseVCloudExpressRestClientModule; @@ -46,7 +49,7 @@ import com.google.common.collect.Maps; import com.google.inject.Provides; public abstract class TerremarkRestClientModule - extends BaseVCloudExpressRestClientModule { + extends BaseVCloudExpressRestClientModule { public TerremarkRestClientModule(Class syncClientType, Class asyncClientType) { super(syncClientType, asyncClientType); @@ -56,31 +59,26 @@ public abstract class TerremarkRestClientModule, Class> delegateMap) { super(syncClientType, asyncClientType, delegateMap); } - + @Singleton @Provides @Named("CreateInternetService") String provideCreateInternetService() throws IOException { - return Strings2.toStringAndClose(getClass().getResourceAsStream( - "/terremark/CreateInternetService.xml")); + return Strings2.toStringAndClose(getClass().getResourceAsStream("/terremark/CreateInternetService.xml")); } @Singleton @Provides @Named("CreateNodeService") String provideCreateNodeService() throws IOException { - return Strings2.toStringAndClose(getClass().getResourceAsStream( - "/terremark/CreateNodeService.xml")); + return Strings2.toStringAndClose(getClass().getResourceAsStream("/terremark/CreateNodeService.xml")); } @Override protected void bindErrorHandlers() { - bind(HttpErrorHandler.class).annotatedWith(Redirection.class).to( - ParseTerremarkVCloudErrorFromHttpResponse.class); - bind(HttpErrorHandler.class).annotatedWith(ClientError.class).to( - ParseTerremarkVCloudErrorFromHttpResponse.class); - bind(HttpErrorHandler.class).annotatedWith(ServerError.class).to( - ParseTerremarkVCloudErrorFromHttpResponse.class); + bind(HttpErrorHandler.class).annotatedWith(Redirection.class).to(ParseTerremarkVCloudErrorFromHttpResponse.class); + bind(HttpErrorHandler.class).annotatedWith(ClientError.class).to(ParseTerremarkVCloudErrorFromHttpResponse.class); + bind(HttpErrorHandler.class).annotatedWith(ServerError.class).to(ParseTerremarkVCloudErrorFromHttpResponse.class); } @Singleton @@ -111,14 +109,10 @@ public abstract class TerremarkRestClientModule> provideOrgToKeysListCache( - @Named(PROPERTY_SESSION_INTERVAL) long seconds, final OrgNameToKeysListSupplier supplier) { - return new MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier>(authException, - seconds, new Supplier>() { - @Override - public Map get() { - return supplier.get(); - } - }); + @Named(PROPERTY_SESSION_INTERVAL) long seconds, AtomicReference authException, + OrgNameToKeysListSupplier supplier) { + return new MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier>( + authException, seconds, supplier); } @Singleton diff --git a/common/trmk/src/main/java/org/jclouds/vcloud/terremark/functions/OrgURIToEndpoint.java b/common/trmk/src/main/java/org/jclouds/vcloud/terremark/functions/OrgURIToEndpoint.java index 208b02560e..798f391d0d 100644 --- a/common/trmk/src/main/java/org/jclouds/vcloud/terremark/functions/OrgURIToEndpoint.java +++ b/common/trmk/src/main/java/org/jclouds/vcloud/terremark/functions/OrgURIToEndpoint.java @@ -23,6 +23,7 @@ import java.util.Map; import org.jclouds.rest.ResourceNotFoundException; import org.jclouds.vcloud.domain.Org; +import org.jclouds.vcloud.domain.ReferenceType; import org.jclouds.vcloud.terremark.domain.TerremarkOrg; import com.google.common.base.Function; @@ -36,9 +37,10 @@ import com.google.common.collect.Maps; public abstract class OrgURIToEndpoint implements Function { protected final Supplier> orgMap; - protected final URI defaultOrg; + protected final ReferenceType defaultOrg; - public OrgURIToEndpoint(Supplier> orgMap, @org.jclouds.vcloud.endpoints.Org URI defaultUri) { + public OrgURIToEndpoint(Supplier> orgMap, + @org.jclouds.vcloud.endpoints.Org ReferenceType defaultUri) { this.orgMap = orgMap; this.defaultOrg = defaultUri; } @@ -53,7 +55,7 @@ public abstract class OrgURIToEndpoint implements Function { }); try { - TerremarkOrg org = TerremarkOrg.class.cast(uriToOrg.get(from == null ? defaultOrg : from)); + TerremarkOrg org = TerremarkOrg.class.cast(uriToOrg.get(from == null ? defaultOrg.getHref() : from)); return getUriFromOrg(org); } catch (NullPointerException e) { throw new ResourceNotFoundException("org " + from + " not found in: " + uriToOrg, e); diff --git a/common/trmk/src/main/java/org/jclouds/vcloud/terremark/functions/OrgURIToKeysListEndpoint.java b/common/trmk/src/main/java/org/jclouds/vcloud/terremark/functions/OrgURIToKeysListEndpoint.java index 4f670f6759..be45bb7ae9 100644 --- a/common/trmk/src/main/java/org/jclouds/vcloud/terremark/functions/OrgURIToKeysListEndpoint.java +++ b/common/trmk/src/main/java/org/jclouds/vcloud/terremark/functions/OrgURIToKeysListEndpoint.java @@ -25,6 +25,7 @@ import javax.inject.Inject; import javax.inject.Singleton; import org.jclouds.vcloud.domain.Org; +import org.jclouds.vcloud.domain.ReferenceType; import org.jclouds.vcloud.terremark.domain.TerremarkOrg; import com.google.common.base.Function; @@ -38,7 +39,7 @@ import com.google.common.base.Supplier; public class OrgURIToKeysListEndpoint extends OrgURIToEndpoint implements Function { @Inject public OrgURIToKeysListEndpoint(Supplier> orgMap, - @org.jclouds.vcloud.endpoints.Org URI defaultUri) { + @org.jclouds.vcloud.endpoints.Org ReferenceType defaultUri) { super(orgMap, defaultUri); } diff --git a/common/trmk/src/main/java/org/jclouds/vcloud/terremark/functions/VDCURIToInternetServicesEndpoint.java b/common/trmk/src/main/java/org/jclouds/vcloud/terremark/functions/VDCURIToInternetServicesEndpoint.java index 4d522c8034..40d1e03461 100644 --- a/common/trmk/src/main/java/org/jclouds/vcloud/terremark/functions/VDCURIToInternetServicesEndpoint.java +++ b/common/trmk/src/main/java/org/jclouds/vcloud/terremark/functions/VDCURIToInternetServicesEndpoint.java @@ -25,6 +25,7 @@ import javax.inject.Inject; import javax.inject.Singleton; import org.jclouds.rest.ResourceNotFoundException; +import org.jclouds.vcloud.domain.ReferenceType; import org.jclouds.vcloud.endpoints.VDC; import org.jclouds.vcloud.terremark.domain.TerremarkVDC; @@ -38,19 +39,19 @@ import com.google.common.base.Supplier; @Singleton public class VDCURIToInternetServicesEndpoint implements Function { private final Supplier> orgVDCMap; - private final URI defaultVDC; + private final ReferenceType defaultVDC; @Inject public VDCURIToInternetServicesEndpoint(Supplier> orgVDCMap, - @VDC URI defaultVDC) { + @VDC ReferenceType defaultVDC) { this.orgVDCMap = orgVDCMap; this.defaultVDC = defaultVDC; } public URI apply(Object from) { try { - return TerremarkVDC.class.cast(orgVDCMap.get().get(from == null ? defaultVDC : from)).getInternetServices() - .getHref(); + return TerremarkVDC.class.cast(orgVDCMap.get().get(from == null ? defaultVDC.getHref() : from)) + .getInternetServices().getHref(); } catch (NullPointerException e) { throw new ResourceNotFoundException("vdc " + from + " not found in " + orgVDCMap.get()); } diff --git a/common/trmk/src/main/java/org/jclouds/vcloud/terremark/functions/VDCURIToPublicIPsEndpoint.java b/common/trmk/src/main/java/org/jclouds/vcloud/terremark/functions/VDCURIToPublicIPsEndpoint.java index ff93df6683..3447c26a2a 100644 --- a/common/trmk/src/main/java/org/jclouds/vcloud/terremark/functions/VDCURIToPublicIPsEndpoint.java +++ b/common/trmk/src/main/java/org/jclouds/vcloud/terremark/functions/VDCURIToPublicIPsEndpoint.java @@ -25,6 +25,7 @@ import javax.inject.Inject; import javax.inject.Singleton; import org.jclouds.rest.ResourceNotFoundException; +import org.jclouds.vcloud.domain.ReferenceType; import org.jclouds.vcloud.endpoints.VDC; import org.jclouds.vcloud.terremark.domain.TerremarkVDC; @@ -38,18 +39,19 @@ import com.google.common.base.Supplier; @Singleton public class VDCURIToPublicIPsEndpoint implements Function { private final Supplier> orgVDCMap; - private final URI defaultVDC; + private final ReferenceType defaultVDC; @Inject public VDCURIToPublicIPsEndpoint(Supplier> orgVDCMap, - @VDC URI defaultVDC) { + @VDC ReferenceType defaultVDC) { this.orgVDCMap = orgVDCMap; this.defaultVDC = defaultVDC; } public URI apply(Object from) { try { - return TerremarkVDC.class.cast(orgVDCMap.get().get(from == null ? defaultVDC : from)).getPublicIps().getHref(); + return TerremarkVDC.class.cast(orgVDCMap.get().get(from == null ? defaultVDC.getHref() : from)).getPublicIps() + .getHref(); } catch (NullPointerException e) { throw new ResourceNotFoundException("vdc " + from + " not found in " + orgVDCMap.get()); } diff --git a/common/trmk/src/test/java/org/jclouds/vcloud/terremark/TerremarkClientLiveTest.java b/common/trmk/src/test/java/org/jclouds/vcloud/terremark/TerremarkClientLiveTest.java index 74d6934adf..c4d1071369 100644 --- a/common/trmk/src/test/java/org/jclouds/vcloud/terremark/TerremarkClientLiveTest.java +++ b/common/trmk/src/test/java/org/jclouds/vcloud/terremark/TerremarkClientLiveTest.java @@ -54,6 +54,7 @@ import org.jclouds.ssh.jsch.config.JschSshClientModule; import org.jclouds.vcloud.VCloudExpressClientLiveTest; import org.jclouds.vcloud.VCloudExpressMediaType; import org.jclouds.vcloud.domain.Catalog; +import org.jclouds.vcloud.domain.Org; import org.jclouds.vcloud.domain.ReferenceType; import org.jclouds.vcloud.domain.Status; import org.jclouds.vcloud.domain.Task; @@ -64,10 +65,12 @@ import org.jclouds.vcloud.options.CloneVAppOptions; import org.jclouds.vcloud.predicates.TaskSuccess; import org.jclouds.vcloud.terremark.domain.CustomizationParameters; import org.jclouds.vcloud.terremark.domain.InternetService; +import org.jclouds.vcloud.terremark.domain.KeyPair; import org.jclouds.vcloud.terremark.domain.Node; import org.jclouds.vcloud.terremark.domain.Protocol; import org.jclouds.vcloud.terremark.domain.PublicIpAddress; import org.jclouds.vcloud.terremark.domain.TerremarkCatalogItem; +import org.jclouds.vcloud.terremark.domain.TerremarkOrg; import org.jclouds.vcloud.terremark.domain.TerremarkVDC; import org.jclouds.vcloud.terremark.options.AddInternetServiceOptions; import org.jclouds.vcloud.terremark.options.TerremarkInstantiateVAppTemplateOptions; @@ -99,49 +102,65 @@ public abstract class TerremarkClientLiveTest extends VCloudExpressClientLiveTes protected VCloudExpressVApp clone; protected VDC vdc; public static final String PREFIX = System.getProperty("user.name") + "-terremark"; - + @Test - public void testListOrgs() throws Exception { - for (ReferenceType org : tmClient.listOrgs()) { - assertNotNull(tmClient.getOrg(org.getHref())); + public void testKeysList() throws Exception { + for (Org oorg : orgs) { + TerremarkVCloudClient vCloudExpressClient = TerremarkVCloudClient.class.cast(tmClient); + TerremarkOrg org = (TerremarkOrg) oorg; + Set response = vCloudExpressClient.listKeyPairsInOrg(org.getHref()); + assertNotNull(response); } } - + @Test public void testGetAllInternetServices() throws Exception { - for (InternetService service : tmClient.getAllInternetServicesInVDC(tmClient.findVDCInOrgNamed(null, null) - .getHref())) { - assertNotNull(tmClient.getNodes(service.getId())); + for (Org org : orgs) { + for (ReferenceType vdc : org.getVDCs().values()) { + for (InternetService service : tmClient.getAllInternetServicesInVDC(vdc.getHref())) { + assertNotNull(tmClient.getNodes(service.getId())); + } + } } } @Test public void testCreateInternetServiceMonitorDisabled() throws Exception { - VDC vdc = tmClient.findVDCInOrgNamed(null, null); - Set publicIpAddresses = tmClient.getPublicIpsAssociatedWithVDC(vdc.getHref()); - PublicIpAddress publicIp = publicIpAddresses.iterator().next(); - - InternetService service = tmClient.addInternetServiceToExistingIp(publicIp.getId(), PREFIX + "-no-monitoring", - Protocol.TCP, 1234, AddInternetServiceOptions.Builder.monitorDisabled()); - tmClient.deleteInternetService(service.getId()); + for (Org org : orgs) { + for (ReferenceType vdc : org.getVDCs().values()) { + Set publicIpAddresses = tmClient.getPublicIpsAssociatedWithVDC(vdc.getHref()); + PublicIpAddress publicIp = publicIpAddresses.iterator().next(); + InternetService service = tmClient.addInternetServiceToExistingIp(publicIp.getId(), PREFIX + + "-no-monitoring", Protocol.TCP, 1234, AddInternetServiceOptions.Builder.monitorDisabled()); + tmClient.deleteInternetService(service.getId()); + } + } } @Test public void testGetPublicIpsAssociatedWithVDC() throws Exception { - for (PublicIpAddress ip : tmClient - .getPublicIpsAssociatedWithVDC(tmClient.findVDCInOrgNamed(null, null).getHref())) { - assertNotNull(tmClient.getInternetServicesOnPublicIp(ip.getId())); - assertNotNull(tmClient.getPublicIp(ip.getId())); + for (Org org : orgs) { + for (ReferenceType vdc : org.getVDCs().values()) { + for (PublicIpAddress ip : tmClient.getPublicIpsAssociatedWithVDC(vdc.getHref())) { + assertNotNull(tmClient.getInternetServicesOnPublicIp(ip.getId())); + assertNotNull(tmClient.getPublicIp(ip.getId())); + } + } } } @Test public void testGetConfigCustomizationOptions() throws Exception { - Catalog response = connection.findCatalogInOrgNamed(null, null); - for (ReferenceType resource : response.values()) { - if (resource.getType().equals(VCloudExpressMediaType.CATALOGITEM_XML)) { - TerremarkCatalogItem item = tmClient.findCatalogItemInOrgCatalogNamed(null, null, resource.getName()); - assert tmClient.getCustomizationOptions(item.getCustomizationOptions().getHref()) != null; + for (Org org : orgs) { + for (ReferenceType catalog : org.getCatalogs().values()) { + Catalog response = connection.getCatalog(catalog.getHref()); + for (ReferenceType resource : response.values()) { + if (resource.getType().equals(VCloudExpressMediaType.CATALOGITEM_XML)) { + TerremarkCatalogItem item = tmClient.findCatalogItemInOrgCatalogNamed(org.getName(), + catalog.getName(), resource.getName()); + assert tmClient.getCustomizationOptions(item.getCustomizationOptions().getHref()) != null; + } + } } } } @@ -149,16 +168,20 @@ public abstract class TerremarkClientLiveTest extends VCloudExpressClientLiveTes @Test public void testDefaultVDC() throws Exception { super.testDefaultVDC(); - TerremarkVDC response = (TerremarkVDC) tmClient.findVDCInOrgNamed(null, null); - assertNotNull(response); - assertNotNull(response.getCatalog()); - assertNotNull(response.getInternetServices()); - assertNotNull(response.getPublicIps()); + for (Org org : orgs) { + for (ReferenceType vdc : org.getVDCs().values()) { + TerremarkVDC response = (TerremarkVDC) tmClient.getVDC(vdc.getHref()); + assertNotNull(response); + assertNotNull(response.getCatalog()); + assertNotNull(response.getInternetServices()); + assertNotNull(response.getPublicIps()); + } + } } @Test(enabled = true) public void testInstantiateAndPowerOn() throws InterruptedException, ExecutionException, TimeoutException, - IOException { + IOException { prepare(); StringBuffer name = new StringBuffer(); for (int i = 0; i < 15; i++) @@ -184,7 +207,7 @@ public abstract class TerremarkClientLiveTest extends VCloudExpressClientLiveTes // if this template supports setting the root password, let's add it to // our options CustomizationParameters customizationOptions = tmClient.getCustomizationOptions(item.getCustomizationOptions() - .getHref()); + .getHref()); if (customizationOptions.canCustomizePassword()) instantiateOptions.withPassword("robotsarefun"); @@ -194,7 +217,7 @@ public abstract class TerremarkClientLiveTest extends VCloudExpressClientLiveTes // instantiate, noting vApp returned has minimal details vApp = tmClient.instantiateVAppTemplateInVDC(vdc.getHref(), vAppTemplate.getHref(), serverName, - instantiateOptions); + instantiateOptions); assertEquals(vApp.getStatus(), Status.RESOLVED); @@ -286,7 +309,7 @@ public abstract class TerremarkClientLiveTest extends VCloudExpressClientLiveTes @Test(enabled = true, dependsOnMethods = { "testInstantiateAndPowerOn", "testAddInternetService" }) public void testPublicIp() throws InterruptedException, ExecutionException, TimeoutException, IOException { node = tmClient.addNode(is.getId(), Iterables.getLast(vApp.getNetworkToAddresses().values()), vApp.getName() - + "-SSH", 22); + + "-SSH", 22); loopAndCheckPass(); } @@ -349,18 +372,18 @@ public abstract class TerremarkClientLiveTest extends VCloudExpressClientLiveTes vApp = tmClient.getVApp(vApp.getHref()); Task task = tmClient.configureVApp(vApp, changeNameTo("eduardo").changeMemoryTo(1536).changeProcessorCountTo(1) - .addDisk(25 * 1048576).addDisk(25 * 1048576)); + .addDisk(25 * 1048576).addDisk(25 * 1048576)); assert successTester.apply(task.getHref()); vApp = tmClient.getVApp(vApp.getHref()); assertEquals(vApp.getName(), "eduardo"); assertEquals(find(vApp.getResourceAllocations(), CIMPredicates.resourceTypeIn(ResourceType.PROCESSOR)) - .getVirtualQuantity().longValue(), 1); + .getVirtualQuantity().longValue(), 1); assertEquals(find(vApp.getResourceAllocations(), CIMPredicates.resourceTypeIn(ResourceType.MEMORY)) - .getVirtualQuantity().longValue(), 1536); + .getVirtualQuantity().longValue(), 1536); assertEquals(size(filter(vApp.getResourceAllocations(), CIMPredicates.resourceTypeIn(ResourceType.DISK_DRIVE))), - 3); + 3); assert successTester.apply(tmClient.powerOnVApp(vApp.getHref()).getHref()); @@ -370,11 +393,11 @@ public abstract class TerremarkClientLiveTest extends VCloudExpressClientLiveTes // extract the disks on the vApp sorted by addressOnParent List disks = Lists.newArrayList(filter(vApp.getResourceAllocations(), - CIMPredicates.resourceTypeIn(ResourceType.DISK_DRIVE))); + CIMPredicates.resourceTypeIn(ResourceType.DISK_DRIVE))); // delete the second disk - task = tmClient.configureVApp(vApp, deleteDiskWithAddressOnParent(Integer.parseInt(disks.get(1) - .getAddressOnParent()))); + task = tmClient.configureVApp(vApp, + deleteDiskWithAddressOnParent(Integer.parseInt(disks.get(1).getAddressOnParent()))); assert successTester.apply(task.getHref()); @@ -383,17 +406,18 @@ public abstract class TerremarkClientLiveTest extends VCloudExpressClientLiveTes } protected void verifyConfigurationOfVApp(VCloudExpressVApp vApp, String serverName, String expectedOs, - int processorCount, long memory, long hardDisk) { + int processorCount, long memory, long hardDisk) { assertEquals(vApp.getName(), serverName); assertEquals(vApp.getOperatingSystemDescription(), expectedOs); assertEquals((int) find(vApp.getResourceAllocations(), CIMPredicates.resourceTypeIn(ResourceType.PROCESSOR)) - .getVirtualQuantity().longValue(), processorCount); + .getVirtualQuantity().longValue(), processorCount); assertEquals(find(vApp.getResourceAllocations(), CIMPredicates.resourceTypeIn(ResourceType.MEMORY)) - .getVirtualQuantity().longValue(), memory); + .getVirtualQuantity().longValue(), memory); assertEquals(find(vApp.getResourceAllocations(), CIMPredicates.resourceTypeIn(ResourceType.DISK_DRIVE)) - .getVirtualQuantity().longValue(), hardDisk); - assertEquals(vApp.getSize().longValue(), find(vApp.getResourceAllocations(), - CIMPredicates.resourceTypeIn(ResourceType.DISK_DRIVE)).getVirtualQuantity().longValue()); + .getVirtualQuantity().longValue(), hardDisk); + assertEquals(vApp.getSize().longValue(), + find(vApp.getResourceAllocations(), CIMPredicates.resourceTypeIn(ResourceType.DISK_DRIVE)) + .getVirtualQuantity().longValue()); } protected void doCheckPass(String address) throws IOException { @@ -476,8 +500,7 @@ public abstract class TerremarkClientLiveTest extends VCloudExpressClientLiveTes Properties overrides = setupProperties(); injector = new RestContextFactory().createContextBuilder(provider, - ImmutableSet. of(new Log4JLoggingModule(), new JschSshClientModule()), overrides) - .buildInjector(); + ImmutableSet. of(new Log4JLoggingModule(), new JschSshClientModule()), overrides).buildInjector(); connection = tmClient = injector.getInstance(TerremarkVCloudClient.class); diff --git a/common/trmk/src/test/java/org/jclouds/vcloud/terremark/binders/TerremarkBindInstantiateVAppTemplateParamsToXmlPayloadTest.java b/common/trmk/src/test/java/org/jclouds/vcloud/terremark/binders/TerremarkBindInstantiateVAppTemplateParamsToXmlPayloadTest.java index 721c9f6bdc..df11a07c77 100644 --- a/common/trmk/src/test/java/org/jclouds/vcloud/terremark/binders/TerremarkBindInstantiateVAppTemplateParamsToXmlPayloadTest.java +++ b/common/trmk/src/test/java/org/jclouds/vcloud/terremark/binders/TerremarkBindInstantiateVAppTemplateParamsToXmlPayloadTest.java @@ -32,6 +32,8 @@ import javax.inject.Singleton; import org.jclouds.rest.internal.GeneratedHttpRequest; import org.jclouds.util.Strings2; +import org.jclouds.vcloud.domain.ReferenceType; +import org.jclouds.vcloud.domain.internal.ReferenceTypeImpl; import org.jclouds.vcloud.domain.network.NetworkConfig; import org.jclouds.vcloud.endpoints.Network; import org.jclouds.vcloud.terremark.TerremarkVCloudPropertiesBuilder; @@ -68,8 +70,8 @@ public class TerremarkBindInstantiateVAppTemplateParamsToXmlPayloadTest { @Network @Provides @Singleton - URI provideNetwork() { - return URI.create("https://vcloud.safesecureweb.com/network/1990"); + ReferenceType provideNetwork() { + return new ReferenceTypeImpl(null, null, URI.create("https://vcloud.safesecureweb.com/network/1990")); } }); diff --git a/common/vcloud/src/main/java/org/jclouds/vcloud/compute/config/CommonVCloudBindComputeSuppliersByClass.java b/common/vcloud/src/main/java/org/jclouds/vcloud/compute/config/CommonVCloudBindComputeSuppliersByClass.java index 15c7153f43..b65746e016 100644 --- a/common/vcloud/src/main/java/org/jclouds/vcloud/compute/config/CommonVCloudBindComputeSuppliersByClass.java +++ b/common/vcloud/src/main/java/org/jclouds/vcloud/compute/config/CommonVCloudBindComputeSuppliersByClass.java @@ -18,16 +18,27 @@ */ package org.jclouds.vcloud.compute.config; +import static com.google.common.base.Preconditions.checkNotNull; +import static com.google.common.collect.Iterables.find; + import java.util.Set; +import javax.inject.Inject; +import javax.inject.Singleton; + +import org.jclouds.collect.Memoized; import org.jclouds.compute.config.BindComputeSuppliersByClass; import org.jclouds.compute.domain.Hardware; import org.jclouds.compute.domain.Image; import org.jclouds.domain.Location; +import org.jclouds.domain.LocationScope; import org.jclouds.vcloud.compute.suppliers.OrgAndVDCToLocationSupplier; import org.jclouds.vcloud.compute.suppliers.StaticHardwareSupplier; import org.jclouds.vcloud.compute.suppliers.VCloudImageSupplier; +import org.jclouds.vcloud.domain.ReferenceType; +import org.jclouds.vcloud.endpoints.VDC; +import com.google.common.base.Predicate; import com.google.common.base.Supplier; /** @@ -48,4 +59,47 @@ public class CommonVCloudBindComputeSuppliersByClass extends BindComputeSupplier protected Class>> defineLocationSupplier() { return OrgAndVDCToLocationSupplier.class; } + + @Override + protected Class> defineDefaultLocationSupplier() { + return DefaultVDC.class; + } + + @Singleton + public static class DefaultVDC implements Supplier { + @Singleton + public static final class IsDefaultVDC implements Predicate { + private final ReferenceType defaultVDC; + + @Inject + IsDefaultVDC(@VDC ReferenceType defaultVDC) { + this.defaultVDC = checkNotNull(defaultVDC, "defaultVDC"); + } + + @Override + public boolean apply(Location input) { + return input.getScope() == LocationScope.ZONE && input.getId().equals(defaultVDC.getHref().toASCIIString()); + } + + @Override + public String toString() { + return "isDefaultVDC()"; + } + } + + private final Supplier> locationsSupplier; + private final IsDefaultVDC isDefaultVDC; + + @Inject + DefaultVDC(@Memoized Supplier> locationsSupplier, IsDefaultVDC isDefaultVDC) { + this.locationsSupplier = checkNotNull(locationsSupplier, "locationsSupplierSupplier"); + this.isDefaultVDC = checkNotNull(isDefaultVDC, "isDefaultVDC"); + } + + @Override + public Location get() { + return find(locationsSupplier.get(), isDefaultVDC); + } + + } } \ No newline at end of file diff --git a/common/vcloud/src/main/java/org/jclouds/vcloud/config/CommonVCloudRestClientModule.java b/common/vcloud/src/main/java/org/jclouds/vcloud/config/CommonVCloudRestClientModule.java index 58e587eae8..95dcf06a98 100644 --- a/common/vcloud/src/main/java/org/jclouds/vcloud/config/CommonVCloudRestClientModule.java +++ b/common/vcloud/src/main/java/org/jclouds/vcloud/config/CommonVCloudRestClientModule.java @@ -21,30 +21,23 @@ package org.jclouds.vcloud.config; import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkState; import static com.google.common.collect.Iterables.concat; -import static com.google.common.collect.Iterables.find; -import static com.google.common.collect.Iterables.get; import static com.google.common.collect.Iterables.getLast; import static com.google.common.collect.Iterables.transform; -import static com.google.common.collect.Maps.newLinkedHashMap; import static com.google.common.collect.Maps.transformValues; import static com.google.common.collect.Maps.uniqueIndex; import static org.jclouds.Constants.PROPERTY_API_VERSION; -import static org.jclouds.Constants.PROPERTY_IDENTITY; import static org.jclouds.Constants.PROPERTY_SESSION_INTERVAL; -import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_DEFAULT_NETWORK; import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_TIMEOUT_TASK_COMPLETED; import java.net.URI; import java.util.Map; -import java.util.NoSuchElementException; -import java.util.SortedMap; import java.util.Map.Entry; +import java.util.SortedMap; import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; import java.util.concurrent.atomic.AtomicReference; -import javax.annotation.Resource; import javax.inject.Inject; import javax.inject.Named; import javax.inject.Singleton; @@ -55,7 +48,6 @@ import org.jclouds.http.RequiresHttp; import org.jclouds.http.annotation.ClientError; import org.jclouds.http.annotation.Redirection; import org.jclouds.http.annotation.ServerError; -import org.jclouds.logging.Logger; import org.jclouds.predicates.RetryablePredicate; import org.jclouds.rest.AsyncClientFactory; import org.jclouds.rest.AuthorizationException; @@ -73,9 +65,7 @@ import org.jclouds.vcloud.domain.Org; import org.jclouds.vcloud.domain.ReferenceType; import org.jclouds.vcloud.domain.VCloudSession; import org.jclouds.vcloud.domain.VDC; -import org.jclouds.vcloud.endpoints.Network; import org.jclouds.vcloud.endpoints.OrgList; -import org.jclouds.vcloud.endpoints.TasksList; import org.jclouds.vcloud.functions.AllCatalogItemsInCatalog; import org.jclouds.vcloud.functions.AllCatalogItemsInOrg; import org.jclouds.vcloud.functions.AllCatalogsInOrg; @@ -87,39 +77,41 @@ import org.jclouds.vcloud.predicates.TaskSuccess; import com.google.common.base.Function; import com.google.common.base.Predicate; -import com.google.common.base.Predicates; import com.google.common.base.Supplier; -import com.google.common.collect.Iterables; -import com.google.inject.ConfigurationException; +import com.google.common.base.Suppliers; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableMap.Builder; import com.google.inject.Injector; -import com.google.inject.Key; import com.google.inject.Provides; import com.google.inject.TypeLiteral; -import com.google.inject.name.Names; /** - * Configures the VCloud authentication service connection, including logging and http transport. + * Configures the VCloud authentication service connection, including logging + * and http transport. * * @author Adrian Cole */ @RequiresHttp @ConfiguresRestClient public class CommonVCloudRestClientModule extends - RestClientModule { + RestClientModule { public CommonVCloudRestClientModule(Class syncClientType, Class asyncClientType) { super(syncClientType, asyncClientType); } public CommonVCloudRestClientModule(Class syncClientType, Class asyncClientType, - Map, Class> delegateMap) { + Map, Class> delegateMap) { super(syncClientType, asyncClientType, delegateMap); } @Override protected void configure() { - requestInjection(this); super.configure(); + // Ensures we don't retry on authorization failures + bind(new TypeLiteral>() { + }).toInstance(new AtomicReference()); + installDefaultVCloudEndpointsModule(); bind(new TypeLiteral>() { }).to(new TypeLiteral() { }); @@ -158,68 +150,29 @@ public class CommonVCloudRestClientModule> provideVDCtoORG(@Named(PROPERTY_SESSION_INTERVAL) long seconds, - final Supplier> orgToVDCSupplier) { - return new MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier>(authException, - seconds, new Supplier>() { - @Override - public Map get() { - Map returnVal = newLinkedHashMap(); - for (Entry orgr : orgToVDCSupplier.get().entrySet()) { - for (String vdc : orgr.getValue().getVDCs().keySet()) { - returnVal.put(vdc, orgr.getKey()); - } - } - return returnVal; - } - }); + protected Supplier> provideVDCtoORG(Supplier> orgNameToOrgSuppier) { + return Suppliers.compose(new Function, Map>() { - } + @Override + public Map apply(Map arg0) { + Builder returnVal = ImmutableMap. builder(); + for (Entry orgr : arg0.entrySet()) { + for (String vdc : orgr.getValue().getVDCs().keySet()) { + returnVal.put(vdc, orgr.getKey()); + } + } + return returnVal.build(); + } + }, orgNameToOrgSuppier); - @Provides - @org.jclouds.vcloud.endpoints.VDC - @Singleton - protected URI provideDefaultVDC(Org org, @org.jclouds.vcloud.endpoints.VDC String defaultVDC) { - checkState(org.getVDCs().size() > 0, "No vdcs present in org %s", org.getName()); - return checkNotNull(org.getVDCs().get(defaultVDC), "vdc %s not present in org %s", defaultVDC, org.getName()) - .getHref(); - } - - @Provides - @org.jclouds.vcloud.endpoints.VDC - @Singleton - protected String provideDefaultVDCName( - @org.jclouds.vcloud.endpoints.VDC Supplier> vDCtoOrgSupplier) { - Map vDCtoOrg = vDCtoOrgSupplier.get(); - checkState(vDCtoOrg.keySet().size() > 0, "No vdcs present!"); - return get(vDCtoOrg.keySet(), 0); - } - - @Provides - @org.jclouds.vcloud.endpoints.Catalog - @Singleton - protected URI provideCatalog(Org org, @Named(PROPERTY_IDENTITY) String user, WriteableCatalog writableCatalog) { - checkState(org.getCatalogs().size() > 0, "No catalogs present in org: " + org.getName()); - try { - return find(org.getCatalogs().values(), writableCatalog).getHref(); - } catch (NoSuchElementException e) { - throw new NoSuchElementException(String.format("no writable catalogs in org %s; catalogs %s", org, org - .getCatalogs())); - } } @Provides @Singleton protected Supplier> provideOrgMapCache(@Named(PROPERTY_SESSION_INTERVAL) long seconds, - final OrgMapSupplier supplier) { + AtomicReference authException, OrgMapSupplier supplier) { return new MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier>( - authException, seconds, new Supplier>() { - @Override - public Map get() { - return supplier.get(); - } - - }); + authException, seconds, supplier); } @Provides @@ -227,33 +180,17 @@ public class CommonVCloudRestClientModule sessionSupplier) { VCloudSession session = sessionSupplier.get(); - return URI.create(Iterables.getLast(session.getOrgs().values()).getHref().toASCIIString().replaceAll("org/.*", - "org")); - } - - @Singleton - public static class WriteableCatalog implements Predicate { - private final CommonVCloudClient client; - - @Inject - public WriteableCatalog(CommonVCloudClient client) { - this.client = client; - } - - @Override - public boolean apply(ReferenceType arg0) { - return !client.getCatalog(arg0.getHref()).isReadOnly(); - } + return URI.create(getLast(session.getOrgs().values()).getHref().toASCIIString().replaceAll("org/.*", "org")); } @Singleton public static class OrgMapSupplier implements Supplier> { protected final Supplier sessionSupplier; - private final Function, Iterable> organizationsForNames; + protected final Function, Iterable> organizationsForNames; @Inject protected OrgMapSupplier(Supplier sessionSupplier, - Function, Iterable> organizationsForNames) { + Function, Iterable> organizationsForNames) { this.sessionSupplier = sessionSupplier; this.organizationsForNames = organizationsForNames; } @@ -264,15 +201,19 @@ public class CommonVCloudRestClientModule>> { + Supplier>> { protected final Supplier> orgSupplier; - private final Function> allCatalogsInOrg; + protected final Function> allCatalogsInOrg; @Inject protected OrgCatalogSupplier(Supplier> orgSupplier, - Function> allCatalogsInOrg) { + Function> allCatalogsInOrg) { this.orgSupplier = orgSupplier; this.allCatalogsInOrg = allCatalogsInOrg; } @@ -280,67 +221,41 @@ public class CommonVCloudRestClientModule> get() { return transformValues( - transformValues(orgSupplier.get(), allCatalogsInOrg), - new Function, Map>() { + transformValues(orgSupplier.get(), allCatalogsInOrg), + new Function, Map>() { - @Override - public Map apply( - Iterable from) { - return uniqueIndex(from, name); - } + @Override + public Map apply( + Iterable from) { + return uniqueIndex(from, name); + } - }); + }); } } - @Resource - protected Logger logger = Logger.NULL; - @VCloudToken @Provides String provideVCloudToken(Supplier cache) { return checkNotNull(cache.get().getVCloudToken(), "No token present in session"); } - @Provides - @org.jclouds.vcloud.endpoints.Org - @Singleton - protected URI provideOrg(@org.jclouds.vcloud.endpoints.Org Iterable orgs) { - return getLast(orgs).getHref(); - } - - @Provides - @org.jclouds.vcloud.endpoints.Org - @Singleton - protected String provideOrgName(@org.jclouds.vcloud.endpoints.Org Iterable orgs) { - return getLast(orgs).getName(); - } - @Provides @org.jclouds.vcloud.endpoints.Org @Singleton protected Supplier> provideVDCtoORG(@Named(PROPERTY_SESSION_INTERVAL) long seconds, - final OrgNameToOrgSupplier supplier) { + AtomicReference authException, OrgNameToOrgSupplier supplier) { return new MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier>( - authException, seconds, new Supplier>() { - @Override - public Map get() { - return supplier.get(); - } - }); + authException, seconds, supplier); } @Provides @Singleton protected Supplier> provideURIToVDC( - @Named(PROPERTY_SESSION_INTERVAL) long seconds, final URItoVDC supplier) { + @Named(PROPERTY_SESSION_INTERVAL) long seconds, AtomicReference authException, + URItoVDC supplier) { return new MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier>( - authException, seconds, new Supplier>() { - @Override - public Map get() { - return supplier.get(); - } - }); + authException, seconds, supplier); } @Singleton @@ -355,39 +270,28 @@ public class CommonVCloudRestClientModule get() { return uniqueIndex( - concat(transform( - orgVDCMap.get().values(), - new Function, Iterable>() { + concat(transform( + orgVDCMap.get().values(), + new Function, Iterable>() { - @Override - public Iterable apply( - Map from) { - return from.values(); - } + @Override + public Iterable apply( + Map from) { + return from.values(); + } - })), new Function() { + })), new Function() { - @Override - public URI apply(org.jclouds.vcloud.domain.VDC from) { - return from.getHref(); - } + @Override + public URI apply(org.jclouds.vcloud.domain.VDC from) { + return from.getHref(); + } - }); + }); } } - @Provides - @org.jclouds.vcloud.endpoints.Org - @Singleton - protected Iterable provideOrgs(Supplier cache, @Named(PROPERTY_IDENTITY) String user) { - VCloudSession discovery = cache.get(); - checkState(discovery.getOrgs().size() > 0, "No orgs present for user: " + user); - return discovery.getOrgs().values(); - } - - protected AtomicReference authException = new AtomicReference(); - final static Function name = new Function() { @Override @@ -401,8 +305,7 @@ public class CommonVCloudRestClientModule versions = versionService.getSupportedVersions().get(180, TimeUnit.SECONDS); checkState(versions.size() > 0, "No versions present"); checkState(versions.containsKey(version), "version " + version + " not present in: " + versions); @@ -433,107 +336,46 @@ public class CommonVCloudRestClientModule>> catalogs) { - return getLast(getLast(catalogs.get().values()).keySet()); - } - - @Provides - @Network - @Singleton - protected URI provideDefaultNetwork(@org.jclouds.vcloud.endpoints.VDC URI defaultVDC, Injector injector) { - if (authException.get() != null) - throw authException.get(); - try { - org.jclouds.vcloud.domain.VDC vDC = injector.getInstance(CommonVCloudClient.class).getVDC(defaultVDC); - Map networks = vDC.getAvailableNetworks(); - checkState(networks.size() > 0, "No networks present in vDC: " + vDC.getName()); - if (networks.size() == 1) - return Iterables.getLast(networks.values()).getHref(); - String networkName = null; - try { - networkName = injector.getInstance(Key.get(String.class, Names.named(PROPERTY_VCLOUD_DEFAULT_NETWORK))); - ReferenceType network = networks.get(Iterables.find(networks.keySet(), Predicates - .containsPattern(networkName))); - return network.getHref(); - } catch (NoSuchElementException e) { - throw new IllegalStateException(String.format("network matching [%s] not in %s", networkName, networks.keySet())); - } catch (ConfigurationException e) { - return findDefaultNetworkForVDC(vDC, networks, injector); - } - } catch (AuthorizationException e) { - authException.set(e); - throw e; - } - } - - protected URI findDefaultNetworkForVDC(org.jclouds.vcloud.domain.VDC vDC, Map networks, - Injector injector) { - logger.warn("default network for vdc %s not set", vDC.getName()); - return Iterables.getLast(networks.values()).getHref(); - } - - @Provides - @Singleton - protected Org provideOrg(CommonVCloudClient discovery) { - if (authException.get() != null) - throw authException.get(); - try { - return discovery.findOrgNamed(null); - } catch (AuthorizationException e) { - authException.set(e); - throw e; - } + protected Org provideOrg(Supplier> orgSupplier, + @org.jclouds.vcloud.endpoints.Org ReferenceType defaultOrg) { + return orgSupplier.get().get(defaultOrg.getName()); } @Provides @Singleton protected Predicate successTester(Injector injector, - @Named(PROPERTY_VCLOUD_TIMEOUT_TASK_COMPLETED) long completed) { + @Named(PROPERTY_VCLOUD_TIMEOUT_TASK_COMPLETED) long completed) { return new RetryablePredicate(injector.getInstance(TaskSuccess.class), completed); } @Provides @Singleton protected Supplier>> provideOrgCatalogItemMapSupplierCache( - @Named(PROPERTY_SESSION_INTERVAL) long seconds, final OrgCatalogSupplier supplier) { + @Named(PROPERTY_SESSION_INTERVAL) long seconds, AtomicReference authException, + OrgCatalogSupplier supplier) { return new MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier>>( - authException, seconds, - new Supplier>>() { - @Override - public Map> get() { - return supplier.get(); - } - - }); + authException, seconds, supplier); } - + @Provides @Singleton protected Supplier>> provideOrgVDCSupplierCache( - @Named(PROPERTY_SESSION_INTERVAL) long seconds, final OrgVDCSupplier supplier) { + @Named(PROPERTY_SESSION_INTERVAL) long seconds, AtomicReference authException, + OrgVDCSupplier supplier) { return new MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier>>( - authException, seconds, - new Supplier>>() { - @Override - public Map> get() { - return supplier.get(); - } - - }); + authException, seconds, supplier); } @Singleton public static class OrgVDCSupplier implements - Supplier>> { + Supplier>> { protected final Supplier> orgSupplier; private final Function> allVDCsInOrg; @Inject protected OrgVDCSupplier(Supplier> orgSupplier, - Function> allVDCsInOrg) { + Function> allVDCsInOrg) { this.orgSupplier = orgSupplier; this.allVDCsInOrg = allVDCsInOrg; } @@ -541,29 +383,29 @@ public class CommonVCloudRestClientModule> get() { return transformValues( - transformValues(orgSupplier.get(), allVDCsInOrg), - new Function, Map>() { + transformValues(orgSupplier.get(), allVDCsInOrg), + new Function, Map>() { - @Override - public Map apply( - Iterable from) { - return uniqueIndex(from, name); - } + @Override + public Map apply( + Iterable from) { + return uniqueIndex(from, name); + } - }); + }); } } @Singleton public static class OrgCatalogItemSupplier implements - Supplier>>> { + Supplier>>> { protected final Supplier>> catalogSupplier; - private final Function> allCatalogItemsInCatalog; + protected final Function> allCatalogItemsInCatalog; @Inject protected OrgCatalogItemSupplier( - Supplier>> catalogSupplier, - Function> allCatalogItemsInCatalog) { + Supplier>> catalogSupplier, + Function> allCatalogItemsInCatalog) { this.catalogSupplier = catalogSupplier; this.allCatalogItemsInCatalog = allCatalogItemsInCatalog; } @@ -571,47 +413,34 @@ public class CommonVCloudRestClientModule>> get() { return transformValues( - catalogSupplier.get(), - new Function, Map>>() { + catalogSupplier.get(), + new Function, Map>>() { - @Override - public Map> apply( - Map from) { - return transformValues( - from, - new Function>() { + @Override + public Map> apply( + Map from) { + return transformValues( + from, + new Function>() { - @Override - public Map apply( - org.jclouds.vcloud.domain.Catalog from) { - return uniqueIndex(allCatalogItemsInCatalog.apply(from), name); - } - }); + @Override + public Map apply(org.jclouds.vcloud.domain.Catalog from) { + return uniqueIndex(allCatalogItemsInCatalog.apply(from), name); + } + }); - } - }); + } + }); } } @Provides @Singleton protected Supplier>>> provideOrgCatalogItemSupplierCache( - @Named(PROPERTY_SESSION_INTERVAL) long seconds, final OrgCatalogItemSupplier supplier) { + @Named(PROPERTY_SESSION_INTERVAL) long seconds, AtomicReference authException, + OrgCatalogItemSupplier supplier) { return new MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier>>>( - authException, seconds, - new Supplier>>>() { - @Override - public Map>> get() { - return supplier.get(); - } - }); - } - - @Provides - @TasksList - @Singleton - protected URI provideDefaultTasksList(Org org) { - return org.getTasksList().getHref(); + authException, seconds, supplier); } @Override diff --git a/common/vcloud/src/main/java/org/jclouds/vcloud/config/DefaultCatalogForOrg.java b/common/vcloud/src/main/java/org/jclouds/vcloud/config/DefaultCatalogForOrg.java new file mode 100644 index 0000000000..122827071c --- /dev/null +++ b/common/vcloud/src/main/java/org/jclouds/vcloud/config/DefaultCatalogForOrg.java @@ -0,0 +1,65 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.jclouds.vcloud.config; + +import static com.google.common.base.Preconditions.checkNotNull; +import static com.google.common.base.Preconditions.checkState; +import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_DEFAULT_CATALOG; + +import java.util.Map; + +import javax.inject.Inject; +import javax.inject.Singleton; + +import org.jclouds.config.ValueOfConfigurationKeyOrNull; +import org.jclouds.vcloud.domain.Org; +import org.jclouds.vcloud.domain.ReferenceType; +import org.jclouds.vcloud.endpoints.Catalog; +import org.jclouds.vcloud.suppliers.OnlyReferenceTypeFirstWithNameMatchingConfigurationKeyOrDefault; + +import com.google.common.base.Function; +import com.google.common.base.Predicate; +import com.google.common.base.Supplier; + +/** + * + * @author Adrian Cole + */ +@Singleton +public class DefaultCatalogForOrg implements Function { + private final OnlyReferenceTypeFirstWithNameMatchingConfigurationKeyOrDefault selector; + private final Supplier> nameToOrg; + + @Inject + public DefaultCatalogForOrg(ValueOfConfigurationKeyOrNull valueOfConfigurationKeyOrNull, + @Catalog Predicate defaultSelector, Supplier> nameToOrg) { + this.selector = new OnlyReferenceTypeFirstWithNameMatchingConfigurationKeyOrDefault(checkNotNull( + valueOfConfigurationKeyOrNull, "valueOfConfigurationKeyOrNull"), PROPERTY_VCLOUD_DEFAULT_CATALOG, + checkNotNull(defaultSelector, "defaultSelector")); + this.nameToOrg = checkNotNull(nameToOrg, "nameToOrg"); + } + + @Override + public ReferenceType apply(ReferenceType defaultOrg) { + org.jclouds.vcloud.domain.Org org = nameToOrg.get().get(defaultOrg.getName()); + checkState(org != null, "could not retrieve Org at %s", defaultOrg); + return selector.apply(org.getCatalogs().values()); + } + +} \ No newline at end of file diff --git a/common/vcloud/src/main/java/org/jclouds/vcloud/config/DefaultNetworkForVDC.java b/common/vcloud/src/main/java/org/jclouds/vcloud/config/DefaultNetworkForVDC.java new file mode 100644 index 0000000000..2888037c19 --- /dev/null +++ b/common/vcloud/src/main/java/org/jclouds/vcloud/config/DefaultNetworkForVDC.java @@ -0,0 +1,68 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.jclouds.vcloud.config; + +import static com.google.common.base.Preconditions.checkNotNull; +import static com.google.common.base.Preconditions.checkState; +import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_DEFAULT_NETWORK; + +import java.net.URI; +import java.util.Map; + +import javax.inject.Inject; +import javax.inject.Singleton; + +import org.jclouds.config.ValueOfConfigurationKeyOrNull; +import org.jclouds.vcloud.domain.ReferenceType; +import org.jclouds.vcloud.domain.VDC; +import org.jclouds.vcloud.endpoints.Network; +import org.jclouds.vcloud.suppliers.OnlyReferenceTypeFirstWithNameMatchingConfigurationKeyOrDefault; + +import com.google.common.base.Function; +import com.google.common.base.Predicate; +import com.google.common.base.Supplier; + +/** + * + * @author Adrian Cole + */ +@Singleton +public class DefaultNetworkForVDC implements Function { + + private final OnlyReferenceTypeFirstWithNameMatchingConfigurationKeyOrDefault selector; + private final Supplier> uriToVDC; + + @Inject + public DefaultNetworkForVDC(ValueOfConfigurationKeyOrNull valueOfConfigurationKeyOrNull, + @Network Predicate defaultSelector, + Supplier> uriToVDC) { + this.selector = new OnlyReferenceTypeFirstWithNameMatchingConfigurationKeyOrDefault(checkNotNull( + valueOfConfigurationKeyOrNull, "valueOfConfigurationKeyOrNull"), PROPERTY_VCLOUD_DEFAULT_NETWORK, + checkNotNull(defaultSelector, "defaultSelector")); + this.uriToVDC = checkNotNull(uriToVDC, "uriToVDC"); + } + + @Override + public ReferenceType apply(ReferenceType defaultVDC) { + org.jclouds.vcloud.domain.VDC vDC = uriToVDC.get().get(defaultVDC.getHref()); + checkState(vDC != null, "could not retrieve VDC at %s", defaultVDC); + return selector.apply(vDC.getAvailableNetworks().values()); + } + +} \ No newline at end of file diff --git a/common/vcloud/src/main/java/org/jclouds/vcloud/config/DefaultOrgForUser.java b/common/vcloud/src/main/java/org/jclouds/vcloud/config/DefaultOrgForUser.java new file mode 100644 index 0000000000..6c7cff4db0 --- /dev/null +++ b/common/vcloud/src/main/java/org/jclouds/vcloud/config/DefaultOrgForUser.java @@ -0,0 +1,64 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.session/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.vcloud.config; + +import static com.google.common.base.Preconditions.checkNotNull; +import static com.google.common.base.Preconditions.checkState; +import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_DEFAULT_ORG; + +import javax.inject.Inject; +import javax.inject.Singleton; + +import org.jclouds.config.ValueOfConfigurationKeyOrNull; +import org.jclouds.vcloud.domain.ReferenceType; +import org.jclouds.vcloud.domain.VCloudSession; +import org.jclouds.vcloud.endpoints.Org; +import org.jclouds.vcloud.suppliers.OnlyReferenceTypeFirstWithNameMatchingConfigurationKeyOrDefault; + +import com.google.common.base.Function; +import com.google.common.base.Predicate; +import com.google.common.base.Supplier; + +/** + * + * @author Adrian Cole + */ +@Singleton +public class DefaultOrgForUser implements Function { + + private final OnlyReferenceTypeFirstWithNameMatchingConfigurationKeyOrDefault selector; + private final Supplier sessionSupplier; + + @Inject + public DefaultOrgForUser(ValueOfConfigurationKeyOrNull valueOfConfigurationKeyOrNull, + @Org Predicate defaultSelector, Supplier sessionSupplier) { + this.selector = new OnlyReferenceTypeFirstWithNameMatchingConfigurationKeyOrDefault(checkNotNull( + valueOfConfigurationKeyOrNull, "valueOfConfigurationKeyOrNull"), PROPERTY_VCLOUD_DEFAULT_ORG, checkNotNull( + defaultSelector, "defaultSelector")); + this.sessionSupplier = checkNotNull(sessionSupplier, "sessionSupplier"); + } + + @Override + public ReferenceType apply(String user) { + VCloudSession session = sessionSupplier.get(); + checkState(session != null, "could not retrieve Session at %s", user); + return selector.apply(session.getOrgs().values()); + } + +} \ No newline at end of file diff --git a/common/vcloud/src/main/java/org/jclouds/vcloud/config/DefaultTasksListForOrg.java b/common/vcloud/src/main/java/org/jclouds/vcloud/config/DefaultTasksListForOrg.java new file mode 100644 index 0000000000..85f624f6ab --- /dev/null +++ b/common/vcloud/src/main/java/org/jclouds/vcloud/config/DefaultTasksListForOrg.java @@ -0,0 +1,55 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.jclouds.vcloud.config; + +import static com.google.common.base.Preconditions.checkNotNull; +import static com.google.common.base.Preconditions.checkState; + +import java.util.Map; + +import javax.inject.Inject; +import javax.inject.Singleton; + +import org.jclouds.vcloud.domain.Org; +import org.jclouds.vcloud.domain.ReferenceType; + +import com.google.common.base.Function; +import com.google.common.base.Supplier; + +/** + * + * @author Adrian Cole + */ +@Singleton +public class DefaultTasksListForOrg implements Function { + private final Supplier> nameToOrg; + + @Inject + public DefaultTasksListForOrg(Supplier> nameToOrg) { + this.nameToOrg = checkNotNull(nameToOrg, "nameToOrg"); + } + + @Override + public ReferenceType apply(ReferenceType defaultOrg) { + org.jclouds.vcloud.domain.Org org = nameToOrg.get().get(defaultOrg.getName()); + checkState(org != null, "could not retrieve Org at %s", defaultOrg); + return org.getTasksList(); + } + +} \ No newline at end of file diff --git a/common/vcloud/src/main/java/org/jclouds/vcloud/config/DefaultVCloudReferencesModule.java b/common/vcloud/src/main/java/org/jclouds/vcloud/config/DefaultVCloudReferencesModule.java new file mode 100644 index 0000000000..72a21e3fa5 --- /dev/null +++ b/common/vcloud/src/main/java/org/jclouds/vcloud/config/DefaultVCloudReferencesModule.java @@ -0,0 +1,175 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.jclouds.vcloud.config; + +import static org.jclouds.Constants.PROPERTY_IDENTITY; + +import java.net.URI; +import java.util.Map; + +import javax.annotation.Resource; +import javax.inject.Inject; +import javax.inject.Named; +import javax.inject.Singleton; + +import org.jclouds.logging.Logger; +import org.jclouds.vcloud.domain.Catalog; +import org.jclouds.vcloud.domain.ReferenceType; + +import com.google.common.base.Function; +import com.google.common.base.Predicate; +import com.google.common.base.Predicates; +import com.google.common.base.Supplier; +import com.google.common.base.Suppliers; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableMap.Builder; +import com.google.inject.AbstractModule; +import com.google.inject.Injector; +import com.google.inject.Provides; + +/** + * + * @author Adrian Cole + */ +public class DefaultVCloudReferencesModule extends AbstractModule { + + @Override + protected void configure() { + + } + + @Provides + @org.jclouds.vcloud.endpoints.Org + @Singleton + protected ReferenceType provideDefaultOrg(DefaultOrgForUser defaultOrgURIForUser, + @Named(PROPERTY_IDENTITY) String user) { + return defaultOrgURIForUser.apply(user); + } + + @Provides + @Singleton + @org.jclouds.vcloud.endpoints.Org + protected Predicate provideDefaultOrgSelector(Injector i) { + return Predicates.alwaysTrue(); + } + + @Provides + @org.jclouds.vcloud.endpoints.TasksList + @Singleton + protected ReferenceType provideDefaultTasksList(DefaultTasksListForOrg defaultTasksListURIForOrg, + @org.jclouds.vcloud.endpoints.Org ReferenceType defaultOrg) { + return defaultTasksListURIForOrg.apply(defaultOrg); + } + + @Provides + @org.jclouds.vcloud.endpoints.Catalog + @Singleton + protected ReferenceType provideDefaultCatalog(DefaultCatalogForOrg defaultCatalogURIForOrg, + @org.jclouds.vcloud.endpoints.Org ReferenceType defaultOrg) { + return defaultCatalogURIForOrg.apply(defaultOrg); + } + + @Provides + @Singleton + @org.jclouds.vcloud.endpoints.Catalog + protected Predicate provideDefaultCatalogSelector(Injector i) { + return i.getInstance(WriteableCatalog.class); + } + + @Provides + @Singleton + protected Supplier> provideCatalogsById( + Supplier>> supplier) { + return Suppliers + .compose( + new Function>, Map>() { + + @Override + public Map apply(Map> arg0) { + Builder builder = ImmutableMap. builder(); + for (Map v1 : arg0.values()) { + for (Catalog v2 : v1.values()) { + builder.put(v2.getHref(), v2); + } + } + return builder.build(); + } + + }, supplier); + } + + @Singleton + public static class WriteableCatalog implements Predicate { + + @Resource + protected Logger logger = Logger.NULL; + + private final Supplier> catalogsByIdSupplier; + + @Inject + public WriteableCatalog(Supplier> catalogsByIdSupplier) { + this.catalogsByIdSupplier = catalogsByIdSupplier; + } + + @Override + public boolean apply(ReferenceType arg0) { + // TODO: this is inefficient, calculating the index each time, but + // shouldn't be added to constructor as the supplier is an expensive + // call + Map index = catalogsByIdSupplier.get(); + Catalog catalog = index.get(arg0.getHref()); + if (catalog == null) { + if (logger.isTraceEnabled()) + logger.trace("didn't find catalog %s", arg0); + return false; + } else + return !catalog.isReadOnly(); + } + } + + @Provides + @org.jclouds.vcloud.endpoints.VDC + @Singleton + protected ReferenceType provideDefaultVDC(DefaultVDCForOrg defaultVDCURIForOrg, + @org.jclouds.vcloud.endpoints.Org ReferenceType defaultOrg) { + return defaultVDCURIForOrg.apply(defaultOrg); + } + + @Provides + @Singleton + @org.jclouds.vcloud.endpoints.VDC + protected Predicate provideDefaultVDCSelector(Injector i) { + return Predicates.alwaysTrue(); + } + + @Provides + @org.jclouds.vcloud.endpoints.Network + @Singleton + protected ReferenceType provideDefaultNetwork(DefaultNetworkForVDC defaultNetworkURIForVDC, + @org.jclouds.vcloud.endpoints.VDC ReferenceType defaultVDC) { + return defaultNetworkURIForVDC.apply(defaultVDC); + } + + @Provides + @Singleton + @org.jclouds.vcloud.endpoints.Network + protected Predicate provideDefaultNetworkSelector(Injector i) { + return Predicates.alwaysTrue(); + } +} diff --git a/common/vcloud/src/main/java/org/jclouds/vcloud/config/DefaultVDCForOrg.java b/common/vcloud/src/main/java/org/jclouds/vcloud/config/DefaultVDCForOrg.java new file mode 100644 index 0000000000..c1a6de5ffa --- /dev/null +++ b/common/vcloud/src/main/java/org/jclouds/vcloud/config/DefaultVDCForOrg.java @@ -0,0 +1,65 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.jclouds.vcloud.config; + +import static com.google.common.base.Preconditions.checkNotNull; +import static com.google.common.base.Preconditions.checkState; +import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_DEFAULT_VDC; + +import java.util.Map; + +import javax.inject.Inject; +import javax.inject.Singleton; + +import org.jclouds.config.ValueOfConfigurationKeyOrNull; +import org.jclouds.vcloud.domain.Org; +import org.jclouds.vcloud.domain.ReferenceType; +import org.jclouds.vcloud.endpoints.VDC; +import org.jclouds.vcloud.suppliers.OnlyReferenceTypeFirstWithNameMatchingConfigurationKeyOrDefault; + +import com.google.common.base.Function; +import com.google.common.base.Predicate; +import com.google.common.base.Supplier; + +/** + * + * @author Adrian Cole + */ +@Singleton +public class DefaultVDCForOrg implements Function { + private final OnlyReferenceTypeFirstWithNameMatchingConfigurationKeyOrDefault selector; + private final Supplier> nameToOrg; + + @Inject + public DefaultVDCForOrg(ValueOfConfigurationKeyOrNull valueOfConfigurationKeyOrNull, + @VDC Predicate defaultSelector, Supplier> nameToOrg) { + this.selector = new OnlyReferenceTypeFirstWithNameMatchingConfigurationKeyOrDefault(checkNotNull( + valueOfConfigurationKeyOrNull, "valueOfConfigurationKeyOrNull"), PROPERTY_VCLOUD_DEFAULT_VDC, checkNotNull( + defaultSelector, "defaultSelector")); + this.nameToOrg = checkNotNull(nameToOrg, "nameToOrg"); + } + + @Override + public ReferenceType apply(ReferenceType defaultOrg) { + org.jclouds.vcloud.domain.Org org = nameToOrg.get().get(defaultOrg.getName()); + checkState(org != null, "could not retrieve Org at %s", defaultOrg); + return selector.apply(org.getVDCs().values()); + } + +} \ No newline at end of file diff --git a/common/vcloud/src/main/java/org/jclouds/vcloud/domain/internal/CatalogItemImpl.java b/common/vcloud/src/main/java/org/jclouds/vcloud/domain/internal/CatalogItemImpl.java index d9cbd08820..0aec6c6f96 100644 --- a/common/vcloud/src/main/java/org/jclouds/vcloud/domain/internal/CatalogItemImpl.java +++ b/common/vcloud/src/main/java/org/jclouds/vcloud/domain/internal/CatalogItemImpl.java @@ -38,8 +38,6 @@ import com.google.common.collect.Maps; */ public class CatalogItemImpl extends ReferenceTypeImpl implements CatalogItem { - /** The serialVersionUID */ - private static final long serialVersionUID = 8464716396538298809L; private final String description; private final ReferenceType entity; private final Map properties = Maps.newLinkedHashMap(); diff --git a/common/vcloud/src/main/java/org/jclouds/vcloud/domain/internal/TasksListImpl.java b/common/vcloud/src/main/java/org/jclouds/vcloud/domain/internal/TasksListImpl.java index 503678fb3b..eb58815f47 100644 --- a/common/vcloud/src/main/java/org/jclouds/vcloud/domain/internal/TasksListImpl.java +++ b/common/vcloud/src/main/java/org/jclouds/vcloud/domain/internal/TasksListImpl.java @@ -32,10 +32,7 @@ import org.jclouds.vcloud.domain.TasksList; */ public class TasksListImpl implements TasksList { private final SortedSet tasks; - private final URI id; - /** The serialVersionUID */ - private static final long serialVersionUID = 8464716396538298809L; public TasksListImpl(URI id, SortedSet tasks) { this.id = id; diff --git a/common/vcloud/src/main/java/org/jclouds/vcloud/functions/OrgNameAndCatalogNameToEndpoint.java b/common/vcloud/src/main/java/org/jclouds/vcloud/functions/OrgNameAndCatalogNameToEndpoint.java index 8972aa4f94..d9dfdb2557 100644 --- a/common/vcloud/src/main/java/org/jclouds/vcloud/functions/OrgNameAndCatalogNameToEndpoint.java +++ b/common/vcloud/src/main/java/org/jclouds/vcloud/functions/OrgNameAndCatalogNameToEndpoint.java @@ -42,15 +42,15 @@ import com.google.common.collect.Iterables; @Singleton public class OrgNameAndCatalogNameToEndpoint implements Function { private final Supplier> orgMap; - private final String defaultOrg; - private final URI defaultUri; + private final ReferenceType defaultOrg; + private final ReferenceType defaultCatalog; @Inject public OrgNameAndCatalogNameToEndpoint(Supplier> orgMap, - @org.jclouds.vcloud.endpoints.Org String defaultOrg, @Catalog URI defaultUri) { + @org.jclouds.vcloud.endpoints.Org ReferenceType defaultOrg, @Catalog ReferenceType defaultCatalog) { this.orgMap = orgMap; this.defaultOrg = defaultOrg; - this.defaultUri = defaultUri; + this.defaultCatalog = defaultCatalog; } @SuppressWarnings("unchecked") @@ -59,9 +59,9 @@ public class OrgNameAndCatalogNameToEndpoint implements Function { Object org = Iterables.get(orgCatalog, 0); Object catalog = Iterables.get(orgCatalog, 1); if (org == null && catalog == null) - return defaultUri; + return defaultCatalog.getHref(); else if (org == null) - org = defaultOrg; + org = defaultOrg.getName(); try { Map catalogs = checkNotNull(orgMap.get().get(org)).getCatalogs(); diff --git a/common/vcloud/src/main/java/org/jclouds/vcloud/functions/OrgNameAndVDCNameToEndpoint.java b/common/vcloud/src/main/java/org/jclouds/vcloud/functions/OrgNameAndVDCNameToEndpoint.java index ffb1686fae..6bba84dc2d 100644 --- a/common/vcloud/src/main/java/org/jclouds/vcloud/functions/OrgNameAndVDCNameToEndpoint.java +++ b/common/vcloud/src/main/java/org/jclouds/vcloud/functions/OrgNameAndVDCNameToEndpoint.java @@ -42,15 +42,15 @@ import com.google.common.collect.Iterables; @Singleton public class OrgNameAndVDCNameToEndpoint implements Function { private final Supplier> orgNameToVDCEndpoint; - private final String defaultOrg; - private final URI defaultUri; + private final ReferenceType defaultOrg; + private final ReferenceType defaultVDC; @Inject public OrgNameAndVDCNameToEndpoint(Supplier> orgNameToVDCEndpoint, - @org.jclouds.vcloud.endpoints.Org String defaultOrg, @VDC URI defaultUri) { + @org.jclouds.vcloud.endpoints.Org ReferenceType defaultOrg, @VDC ReferenceType defaultVDC) { this.orgNameToVDCEndpoint = orgNameToVDCEndpoint; this.defaultOrg = defaultOrg; - this.defaultUri = defaultUri; + this.defaultVDC = defaultVDC; } @SuppressWarnings("unchecked") @@ -59,9 +59,9 @@ public class OrgNameAndVDCNameToEndpoint implements Function { Object org = Iterables.get(orgVdc, 0); Object vdc = Iterables.get(orgVdc, 1); if (org == null && vdc == null) - return defaultUri; + return defaultVDC.getHref(); else if (org == null) - org = defaultOrg; + org = defaultOrg.getName(); try { Map vdcs = checkNotNull(orgNameToVDCEndpoint.get().get(org)).getVDCs(); diff --git a/common/vcloud/src/main/java/org/jclouds/vcloud/functions/OrgNameCatalogNameItemNameToEndpoint.java b/common/vcloud/src/main/java/org/jclouds/vcloud/functions/OrgNameCatalogNameItemNameToEndpoint.java index fd20fea3b9..89d6604e6c 100644 --- a/common/vcloud/src/main/java/org/jclouds/vcloud/functions/OrgNameCatalogNameItemNameToEndpoint.java +++ b/common/vcloud/src/main/java/org/jclouds/vcloud/functions/OrgNameCatalogNameItemNameToEndpoint.java @@ -27,6 +27,7 @@ import java.util.NoSuchElementException; import javax.inject.Inject; import javax.inject.Singleton; +import org.jclouds.vcloud.domain.ReferenceType; import org.jclouds.vcloud.endpoints.Catalog; import org.jclouds.vcloud.endpoints.Org; @@ -41,13 +42,13 @@ import com.google.common.collect.Iterables; @Singleton public class OrgNameCatalogNameItemNameToEndpoint implements Function { private final Supplier>> orgCatalogMap; - private final String defaultOrg; - private final String defaultCatalog; + private final ReferenceType defaultOrg; + private final ReferenceType defaultCatalog; @Inject public OrgNameCatalogNameItemNameToEndpoint( Supplier>> orgCatalogMap, - @Org String defaultOrg, @Catalog String defaultCatalog) { + @Org ReferenceType defaultOrg, @Catalog ReferenceType defaultCatalog) { this.orgCatalogMap = orgCatalogMap; this.defaultOrg = defaultOrg; this.defaultCatalog = defaultCatalog; @@ -60,9 +61,9 @@ public class OrgNameCatalogNameItemNameToEndpoint implements Function catalogs = checkNotNull(orgCatalogMap.get().get(org)); return catalogs.get(catalog).get(catalogItem).getHref(); diff --git a/common/vcloud/src/main/java/org/jclouds/vcloud/functions/OrgNameCatalogNameVAppTemplateNameToEndpoint.java b/common/vcloud/src/main/java/org/jclouds/vcloud/functions/OrgNameCatalogNameVAppTemplateNameToEndpoint.java index 8f0efac7c9..7c34814734 100644 --- a/common/vcloud/src/main/java/org/jclouds/vcloud/functions/OrgNameCatalogNameVAppTemplateNameToEndpoint.java +++ b/common/vcloud/src/main/java/org/jclouds/vcloud/functions/OrgNameCatalogNameVAppTemplateNameToEndpoint.java @@ -28,6 +28,7 @@ import javax.inject.Inject; import javax.inject.Singleton; import org.jclouds.vcloud.domain.CatalogItem; +import org.jclouds.vcloud.domain.ReferenceType; import org.jclouds.vcloud.endpoints.Catalog; import org.jclouds.vcloud.endpoints.Org; @@ -42,13 +43,13 @@ import com.google.common.collect.Iterables; @Singleton public class OrgNameCatalogNameVAppTemplateNameToEndpoint implements Function { private final Supplier>>> orgCatalogItemMap; - private final String defaultOrg; - private final String defaultCatalog; + private final ReferenceType defaultOrg; + private final ReferenceType defaultCatalog; @Inject public OrgNameCatalogNameVAppTemplateNameToEndpoint( Supplier>>> orgCatalogItemMap, - @Org String defaultOrg, @Catalog String defaultCatalog) { + @Org ReferenceType defaultOrg, @Catalog ReferenceType defaultCatalog) { this.orgCatalogItemMap = orgCatalogItemMap; this.defaultOrg = defaultOrg; this.defaultCatalog = defaultCatalog; @@ -61,9 +62,9 @@ public class OrgNameCatalogNameVAppTemplateNameToEndpoint implements Function>> orgCatalogItemMap = this.orgCatalogItemMap.get(); if (!orgCatalogItemMap.containsKey(org)) diff --git a/common/vcloud/src/main/java/org/jclouds/vcloud/functions/OrgNameToEndpoint.java b/common/vcloud/src/main/java/org/jclouds/vcloud/functions/OrgNameToEndpoint.java index 9de5670c67..76f4018ab3 100644 --- a/common/vcloud/src/main/java/org/jclouds/vcloud/functions/OrgNameToEndpoint.java +++ b/common/vcloud/src/main/java/org/jclouds/vcloud/functions/OrgNameToEndpoint.java @@ -38,18 +38,19 @@ import com.google.common.base.Supplier; @Singleton public class OrgNameToEndpoint implements Function { private final Supplier> orgNameToEndpointSupplier; - private final URI defaultUri; + private final ReferenceType defaultOrg; @Inject - public OrgNameToEndpoint(@Org Supplier> orgNameToEndpointSupplier, @Org URI defaultUri) { + public OrgNameToEndpoint(@Org Supplier> orgNameToEndpointSupplier, + @Org ReferenceType defaultOrg) { this.orgNameToEndpointSupplier = orgNameToEndpointSupplier; - this.defaultUri = defaultUri; + this.defaultOrg = defaultOrg; } public URI apply(Object from) { try { Map orgNameToEndpoint = orgNameToEndpointSupplier.get(); - return from == null ? defaultUri : orgNameToEndpoint.get(from).getHref(); + return from == null ? defaultOrg.getHref() : orgNameToEndpoint.get(from).getHref(); } catch (NullPointerException e) { throw new NoSuchElementException("org " + from + " not found in " + orgNameToEndpointSupplier.get().keySet()); } diff --git a/common/vcloud/src/main/java/org/jclouds/vcloud/functions/OrgNameToTasksListEndpoint.java b/common/vcloud/src/main/java/org/jclouds/vcloud/functions/OrgNameToTasksListEndpoint.java index 98293c1c2c..f820ef758a 100644 --- a/common/vcloud/src/main/java/org/jclouds/vcloud/functions/OrgNameToTasksListEndpoint.java +++ b/common/vcloud/src/main/java/org/jclouds/vcloud/functions/OrgNameToTasksListEndpoint.java @@ -28,6 +28,7 @@ import javax.inject.Inject; import javax.inject.Singleton; import org.jclouds.vcloud.domain.Org; +import org.jclouds.vcloud.domain.ReferenceType; import org.jclouds.vcloud.endpoints.TasksList; import com.google.common.base.Function; @@ -40,18 +41,19 @@ import com.google.common.base.Supplier; @Singleton public class OrgNameToTasksListEndpoint implements Function { private final Supplier> orgMap; - private final URI defaultUri; + private final ReferenceType defaultTasksList; @Inject - public OrgNameToTasksListEndpoint(Supplier> orgMap, @TasksList URI defaultUri) { + public OrgNameToTasksListEndpoint(Supplier> orgMap, + @TasksList ReferenceType defaultTasksList) { this.orgMap = orgMap; - this.defaultUri = defaultUri; + this.defaultTasksList = defaultTasksList; } public URI apply(Object from) { Object org = from; if (org == null) - return defaultUri; + return defaultTasksList.getHref(); try { return checkNotNull(orgMap.get().get(org)).getTasksList().getHref(); } catch (NullPointerException e) { diff --git a/common/vcloud/src/main/java/org/jclouds/vcloud/functions/OrgNameVDCNameResourceEntityNameToEndpoint.java b/common/vcloud/src/main/java/org/jclouds/vcloud/functions/OrgNameVDCNameResourceEntityNameToEndpoint.java index 0fc028152e..04c76a193d 100644 --- a/common/vcloud/src/main/java/org/jclouds/vcloud/functions/OrgNameVDCNameResourceEntityNameToEndpoint.java +++ b/common/vcloud/src/main/java/org/jclouds/vcloud/functions/OrgNameVDCNameResourceEntityNameToEndpoint.java @@ -27,6 +27,7 @@ import java.util.NoSuchElementException; import javax.inject.Inject; import javax.inject.Singleton; +import org.jclouds.vcloud.domain.ReferenceType; import org.jclouds.vcloud.endpoints.Org; import org.jclouds.vcloud.endpoints.VDC; @@ -41,13 +42,13 @@ import com.google.common.collect.Iterables; @Singleton public class OrgNameVDCNameResourceEntityNameToEndpoint implements Function { private final Supplier>> orgVDCMap; - private final String defaultOrg; - private final String defaultVDC; + private final ReferenceType defaultOrg; + private final ReferenceType defaultVDC; @Inject public OrgNameVDCNameResourceEntityNameToEndpoint( - Supplier>> orgVDCMap, @Org String defaultOrg, - @VDC String defaultVDC) { + Supplier>> orgVDCMap, @Org ReferenceType defaultOrg, + @VDC ReferenceType defaultVDC) { this.orgVDCMap = orgVDCMap; this.defaultOrg = defaultOrg; this.defaultVDC = defaultVDC; @@ -60,9 +61,9 @@ public class OrgNameVDCNameResourceEntityNameToEndpoint implements Function vDCs = checkNotNull(orgVDCMap.get().get(org)); return vDCs.get(vDC).getResourceEntities().get(entityName).getHref(); diff --git a/common/vcloud/src/main/java/org/jclouds/vcloud/functions/ParseLoginResponseFromHeaders.java b/common/vcloud/src/main/java/org/jclouds/vcloud/functions/ParseLoginResponseFromHeaders.java index 6c71e10d4e..442a75e9d4 100644 --- a/common/vcloud/src/main/java/org/jclouds/vcloud/functions/ParseLoginResponseFromHeaders.java +++ b/common/vcloud/src/main/java/org/jclouds/vcloud/functions/ParseLoginResponseFromHeaders.java @@ -17,7 +17,7 @@ * ==================================================================== */ package org.jclouds.vcloud.functions; - +import static com.google.common.base.Preconditions.checkNotNull; import static org.jclouds.http.HttpUtils.releasePayload; import java.util.Map; @@ -69,7 +69,7 @@ public class ParseLoginResponseFromHeaders implements Function org = factory.create(orgHandlerProvider.get()).parse( - from.getPayload().getInput()); + checkNotNull(from.getPayload().getInput(), "no payload in http response to login request %s", from)); return new VCloudSession() { @VCloudToken diff --git a/common/vcloud/src/main/java/org/jclouds/vcloud/reference/VCloudConstants.java b/common/vcloud/src/main/java/org/jclouds/vcloud/reference/VCloudConstants.java index da91439fd3..12450d5909 100644 --- a/common/vcloud/src/main/java/org/jclouds/vcloud/reference/VCloudConstants.java +++ b/common/vcloud/src/main/java/org/jclouds/vcloud/reference/VCloudConstants.java @@ -25,7 +25,20 @@ package org.jclouds.vcloud.reference; */ public interface VCloudConstants { public static final String PROPERTY_VCLOUD_VERSION_SCHEMA = "jclouds.vcloud.version.schema"; - + /** + * name of the default org that your vApp will join, if an org isn't + * explicitly specified. + */ + public static final String PROPERTY_VCLOUD_DEFAULT_ORG = "jclouds.vcloud.defaults.org"; + /** + * name of the default catalog to query, if it isn't explicitly specified. + */ + public static final String PROPERTY_VCLOUD_DEFAULT_CATALOG = "jclouds.vcloud.defaults.catalog"; + /** + * name of the VDC that your vApp will join, if a vDC isn't explicitly + * specified. + */ + public static final String PROPERTY_VCLOUD_DEFAULT_VDC = "jclouds.vcloud.defaults.vdc"; /** * name of the default network, in the default VDC that your vApp will join. */ diff --git a/common/vcloud/src/main/java/org/jclouds/vcloud/suppliers/OnlyReferenceTypeFirstWithNameMatchingConfigurationKeyOrDefault.java b/common/vcloud/src/main/java/org/jclouds/vcloud/suppliers/OnlyReferenceTypeFirstWithNameMatchingConfigurationKeyOrDefault.java new file mode 100644 index 0000000000..a4924e768d --- /dev/null +++ b/common/vcloud/src/main/java/org/jclouds/vcloud/suppliers/OnlyReferenceTypeFirstWithNameMatchingConfigurationKeyOrDefault.java @@ -0,0 +1,101 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.jclouds.vcloud.suppliers; + +import static com.google.common.base.Preconditions.checkArgument; +import static com.google.common.base.Preconditions.checkNotNull; + +import java.util.NoSuchElementException; + +import org.jclouds.config.ValueOfConfigurationKeyOrNull; +import org.jclouds.vcloud.domain.ReferenceType; + +import com.google.common.base.Function; +import com.google.common.base.Predicate; +import com.google.common.collect.Iterables; + +/** + * + * @author Adrian Cole + */ +public class OnlyReferenceTypeFirstWithNameMatchingConfigurationKeyOrDefault implements + Function, ReferenceType> { + + protected final ValueOfConfigurationKeyOrNull valueOfConfigurationKeyOrNull; + protected final String configurationKey; + protected final Predicate defaultSelector; + + public OnlyReferenceTypeFirstWithNameMatchingConfigurationKeyOrDefault( + ValueOfConfigurationKeyOrNull valueOfConfigurationKeyOrNull, String configurationKey, + Predicate defaultSelector) { + this.configurationKey = checkNotNull(configurationKey, "configurationKey"); + this.valueOfConfigurationKeyOrNull = checkNotNull(valueOfConfigurationKeyOrNull, "valueOfConfigurationKeyOrNull"); + this.defaultSelector = checkNotNull(defaultSelector, "defaultSelector"); + } + + @Override + public ReferenceType apply(Iterable referenceTypes) { + checkNotNull(referenceTypes, "referenceTypes"); + checkArgument(Iterables.size(referenceTypes) > 0, + "No referenceTypes corresponding to configuration key %s present", configurationKey); + if (Iterables.size(referenceTypes) == 1) + return Iterables.getLast(referenceTypes); + String namingPattern = valueOfConfigurationKeyOrNull.apply(configurationKey); + if (namingPattern != null) { + return findReferenceTypeWithNameMatchingPattern(referenceTypes, namingPattern); + } else { + return defaultReferenceType(referenceTypes); + } + } + + public ReferenceType defaultReferenceType(Iterable referenceTypes) { + return Iterables.find(referenceTypes, defaultSelector); + } + + public ReferenceType findReferenceTypeWithNameMatchingPattern(Iterable referenceTypes, + String namingPattern) { + try { + return Iterables.find(referenceTypes, new ReferenceTypeNameMatchesPattern(namingPattern)); + } catch (NoSuchElementException e) { + throw new NoSuchElementException(String.format( + "referenceType matching pattern [%s], corresponding to configuration key %s, not in %s", namingPattern, + configurationKey, referenceTypes)); + } + } + + static class ReferenceTypeNameMatchesPattern implements Predicate { + + private final String namingPattern; + + public ReferenceTypeNameMatchesPattern(String namingPattern) { + this.namingPattern = checkNotNull(namingPattern, "namingPattern"); + } + + @Override + public boolean apply(ReferenceType arg0) { + return arg0.getName().matches(namingPattern); + } + + @Override + public String toString() { + return "nameMatchesPattern(" + namingPattern + ")"; + + } + } +} \ No newline at end of file diff --git a/common/vcloud/src/test/java/org/jclouds/vcloud/CommonVCloudClientLiveTest.java b/common/vcloud/src/test/java/org/jclouds/vcloud/CommonVCloudClientLiveTest.java index 685d5e5b2a..39a03c2f92 100644 --- a/common/vcloud/src/test/java/org/jclouds/vcloud/CommonVCloudClientLiveTest.java +++ b/common/vcloud/src/test/java/org/jclouds/vcloud/CommonVCloudClientLiveTest.java @@ -22,6 +22,7 @@ import static com.google.common.base.Preconditions.checkNotNull; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertNotNull; +import java.util.Map; import java.util.Properties; import org.jclouds.Constants; @@ -37,9 +38,12 @@ import org.jclouds.vcloud.domain.ReferenceType; import org.jclouds.vcloud.domain.Task; import org.jclouds.vcloud.domain.VDC; import org.jclouds.vcloud.domain.network.OrgNetwork; +import org.jclouds.vcloud.reference.VCloudConstants; +import org.testng.annotations.AfterGroups; import org.testng.annotations.BeforeGroups; import org.testng.annotations.Test; +import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; import com.google.inject.Module; @@ -48,58 +52,127 @@ import com.google.inject.Module; * * @author Adrian Cole */ -@Test(groups = "live", sequential = true) +@Test(groups = "live", singleThreaded = true) public abstract class CommonVCloudClientLiveTest { protected S connection; protected RestContext context; + protected abstract Iterable listOrgs(); + @Test public void testOrg() throws Exception { - Org response = connection.findOrgNamed(null); - assertNotNull(response); - assertNotNull(response.getName()); - assert response.getCatalogs().size() >= 1; - assert response.getTasksList() != null; - assert response.getVDCs().size() >= 1; - assertEquals(connection.findOrgNamed(response.getName()), response); + for (Org org : orgs) { + assertNotNull(org); + assertNotNull(org.getName()); + assert org.getCatalogs().size() >= 1; + assert org.getTasksList() != null; + assert org.getVDCs().size() >= 1; + assertEquals(connection.findOrgNamed(org.getName()), org); + } + } + + @Test + public void testPropertiesCanOverrideDefaultOrg() throws Exception { + for (Org org : orgs) { + RestContext newContext = null; + try { + newContext = createContextWithProperties(overrideDefaults(ImmutableMap.of( + VCloudConstants.PROPERTY_VCLOUD_DEFAULT_ORG, org.getName()))); + assertEquals(newContext.getApi().findOrgNamed(null), org); + } finally { + newContext.close(); + } + } + } + + public Properties overrideDefaults(Map overrides) { + Properties properties = setupProperties(); + properties.putAll(overrides); + return properties; } @Test public void testCatalog() throws Exception { - Org org = connection.findOrgNamed(null); - for (ReferenceType cat : org.getCatalogs().values()) { - Catalog response = connection.getCatalog(cat.getHref()); - assertNotNull(response); - assertNotNull(response.getName()); - assertNotNull(response.getHref()); - assertEquals(connection.findCatalogInOrgNamed(null, response.getName()), response); + for (Org org : orgs) { + for (ReferenceType cat : org.getCatalogs().values()) { + Catalog response = connection.getCatalog(cat.getHref()); + assertNotNull(response); + assertNotNull(response.getName()); + assertNotNull(response.getHref()); + assertEquals(connection.findCatalogInOrgNamed(org.getName(), response.getName()), response); + } + } + } + + @Test + public void testPropertiesCanOverrideDefaultCatalog() throws Exception { + for (Org org : orgs) { + for (ReferenceType cat : org.getCatalogs().values()) { + RestContext newContext = null; + try { + newContext = createContextWithProperties(overrideDefaults(ImmutableMap.of( + VCloudConstants.PROPERTY_VCLOUD_DEFAULT_ORG, org.getName(), + VCloudConstants.PROPERTY_VCLOUD_DEFAULT_CATALOG, cat.getName()))); + assertEquals(newContext.getApi().findCatalogInOrgNamed(null, null), connection.getCatalog(cat.getHref())); + } finally { + newContext.close(); + } + } } } @Test public void testGetOrgNetwork() throws Exception { - Org org = connection.findOrgNamed(null); - for (ReferenceType resource : org.getNetworks().values()) { - if (resource.getType().equals(VCloudMediaType.NETWORK_XML)) { - OrgNetwork item = connection.getNetwork(resource.getHref()); - assertNotNull(item); + for (Org org : orgs) { + for (ReferenceType resource : org.getNetworks().values()) { + if (resource.getType().equals(VCloudMediaType.NETWORK_XML)) { + OrgNetwork item = connection.getNetwork(resource.getHref()); + assertNotNull(item); + } } } } @Test public void testGetVDCNetwork() throws Exception { - Org org = connection.findOrgNamed(null); - for (ReferenceType vdc : org.getVDCs().values()) { - VDC response = connection.getVDC(vdc.getHref()); - for (ReferenceType resource : response.getAvailableNetworks().values()) { - if (resource.getType().equals(VCloudMediaType.NETWORK_XML)) { - try { - OrgNetwork item = connection.getNetwork(resource.getHref()); - assertNotNull(item); - } catch (AuthorizationException e) { + for (Org org : orgs) { + for (ReferenceType vdc : org.getVDCs().values()) { + VDC response = connection.getVDC(vdc.getHref()); + for (ReferenceType resource : response.getAvailableNetworks().values()) { + if (resource.getType().equals(VCloudMediaType.NETWORK_XML)) { + try { + OrgNetwork net = connection.getNetwork(resource.getHref()); + assertNotNull(net); + assertNotNull(net.getName()); + assertNotNull(net.getHref()); + assertEquals( + connection.findNetworkInOrgVDCNamed(org.getName(), response.getName(), net.getName()), net); + } catch (AuthorizationException e) { + } + } + } + } + } + } + + @Test + public void testPropertiesCanOverrideDefaultNetwork() throws Exception { + for (Org org : orgs) { + for (ReferenceType vdc : org.getVDCs().values()) { + VDC response = connection.getVDC(vdc.getHref()); + for (ReferenceType net : response.getAvailableNetworks().values()) { + RestContext newContext = null; + try { + newContext = createContextWithProperties(overrideDefaults(ImmutableMap.of( + VCloudConstants.PROPERTY_VCLOUD_DEFAULT_ORG, org.getName(), + VCloudConstants.PROPERTY_VCLOUD_DEFAULT_VDC, vdc.getName(), + VCloudConstants.PROPERTY_VCLOUD_DEFAULT_NETWORK, net.getName()))); + assertEquals(newContext.getApi().findNetworkInOrgVDCNamed(null, null, null), + connection.getNetwork(net.getHref())); + } finally { + newContext.close(); } } } @@ -108,13 +181,14 @@ public abstract class CommonVCloudClientLiveTest newContext = null; + try { + newContext = createContextWithProperties(overrideDefaults(ImmutableMap.of( + VCloudConstants.PROPERTY_VCLOUD_DEFAULT_ORG, org.getName(), + VCloudConstants.PROPERTY_VCLOUD_DEFAULT_VDC, vdc.getName()))); + assertEquals(newContext.getApi().findVDCInOrgNamed(null, null), connection.getVDC(vdc.getHref())); + } finally { + newContext.close(); + } + } } } @Test public void testDefaultTasksList() throws Exception { - org.jclouds.vcloud.domain.TasksList response = connection.findTasksListInOrgNamed(null); - assertNotNull(response); - assertNotNull(response.getLocation()); - assertNotNull(response.getTasks()); - assertEquals(connection.getTasksList(response.getLocation()).getLocation(), response.getLocation()); + for (Org org : orgs) { + org.jclouds.vcloud.domain.TasksList response = connection.findTasksListInOrgNamed(org.getName()); + assertNotNull(response); + assertNotNull(response.getLocation()); + assertNotNull(response.getTasks()); + assertEquals(connection.getTasksList(response.getLocation()).getLocation(), response.getLocation()); + } } @Test public void testGetTask() throws Exception { - org.jclouds.vcloud.domain.TasksList response = connection.findTasksListInOrgNamed(null); - assertNotNull(response); - assertNotNull(response.getLocation()); - assertNotNull(response.getTasks()); - if (response.getTasks().size() > 0) { - Task task = response.getTasks().last(); - assertEquals(connection.getTask(task.getHref()).getHref(), task.getHref()); + for (Org org : orgs) { + org.jclouds.vcloud.domain.TasksList response = connection.findTasksListInOrgNamed(org.getName()); + assertNotNull(response); + assertNotNull(response.getLocation()); + assertNotNull(response.getTasks()); + if (response.getTasks().size() > 0) { + Task task = response.getTasks().last(); + assertEquals(connection.getTask(task.getHref()).getHref(), task.getHref()); + } } } @@ -184,6 +281,7 @@ public abstract class CommonVCloudClientLiveTest orgs; protected void setupCredentials() { identity = checkNotNull(System.getProperty("test." + provider + ".identity"), "test." + provider + ".identity"); @@ -213,10 +311,19 @@ public abstract class CommonVCloudClientLiveTest of(new Log4JLoggingModule()), overrides).getProviderSpecificContext(); - + context = createContextWithProperties(setupProperties()); connection = context.getApi(); + orgs = listOrgs(); } + + public RestContext createContextWithProperties(Properties overrides) { + return new ComputeServiceContextFactory(setupRestProperties()).createContext(provider, + ImmutableSet. of(new Log4JLoggingModule()), overrides).getProviderSpecificContext(); + } + + @AfterGroups(groups = { "live" }) + public void teardownClient() { + context.close(); + } + } diff --git a/common/vcloud/src/test/java/org/jclouds/vcloud/suppliers/OnlyReferenceTypeFirstWithNameMatchingConfigurationKeyOrDefaultTest.java b/common/vcloud/src/test/java/org/jclouds/vcloud/suppliers/OnlyReferenceTypeFirstWithNameMatchingConfigurationKeyOrDefaultTest.java new file mode 100644 index 0000000000..ecb4ae2186 --- /dev/null +++ b/common/vcloud/src/test/java/org/jclouds/vcloud/suppliers/OnlyReferenceTypeFirstWithNameMatchingConfigurationKeyOrDefaultTest.java @@ -0,0 +1,124 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.jclouds.vcloud.suppliers; + +import static org.easymock.classextension.EasyMock.createMock; +import static org.testng.Assert.assertEquals; + +import java.util.NoSuchElementException; + +import org.jclouds.config.ValueOfConfigurationKeyOrNull; +import org.jclouds.vcloud.domain.ReferenceType; +import org.jclouds.vcloud.domain.internal.ReferenceTypeImpl; +import org.testng.annotations.Test; + +import com.google.common.base.Predicates; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableSet; +import com.google.inject.AbstractModule; +import com.google.inject.Guice; +import com.google.inject.name.Names; + +/** + * Tests behavior of + * {@code OnlyReferenceTypeFirstWithNameMatchingConfigurationKeyOrDefault} + * + * @author Adrian Cole + */ +// NOTE:without testName, this will not call @Before* and fail w/NPE during +// surefire +@Test(groups = "unit", testName = "OnlyReferenceTypeFirstWithNameMatchingConfigurationKeyOrDefaultTest") +public class OnlyReferenceTypeFirstWithNameMatchingConfigurationKeyOrDefaultTest { + ValueOfConfigurationKeyOrNull valueOfConfigurationKeyOrNull = new ValueOfConfigurationKeyOrNull( + Guice.createInjector()); + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testIllegalArgumentWhenResourcesEmpty() { + new OnlyReferenceTypeFirstWithNameMatchingConfigurationKeyOrDefault(valueOfConfigurationKeyOrNull, "foo", + Predicates. alwaysTrue()).apply(ImmutableSet. of()); + } + + @Test + public void testReturnsOnlyResource() { + ReferenceType reference = createMock(ReferenceType.class); + + assertEquals(new OnlyReferenceTypeFirstWithNameMatchingConfigurationKeyOrDefault(valueOfConfigurationKeyOrNull, + "foo", Predicates. alwaysTrue()).apply(ImmutableSet. of(reference)), + reference); + + } + + @Test + public void testReturnsFirstResourceWhenConfigurationUnspecified() { + ReferenceType reference1 = createMock(ReferenceType.class); + ReferenceType reference2 = createMock(ReferenceType.class); + + assertEquals(new OnlyReferenceTypeFirstWithNameMatchingConfigurationKeyOrDefault(valueOfConfigurationKeyOrNull, + "foo", Predicates. alwaysTrue()).apply(ImmutableList. of(reference1, + reference2)), reference1); + + } + + @Test + public void testReturnsResourceMatchingDefaultPredicateWhenConfigurationUnspecified() { + ReferenceType reference1 = createMock(ReferenceType.class); + ReferenceType reference2 = createMock(ReferenceType.class); + + assertEquals(new OnlyReferenceTypeFirstWithNameMatchingConfigurationKeyOrDefault(valueOfConfigurationKeyOrNull, + "foo", Predicates.equalTo(reference2)).apply(ImmutableList. of(reference1, reference2)), + reference2); + + } + + @Test + public void testReturnsResourceWithNameMatchingConfigurationKey() { + ReferenceType reference1 = new ReferenceTypeImpl("travis tritt", null, null); + ReferenceType reference2 = new ReferenceTypeImpl("hail mary", null, null); + + assertEquals(new OnlyReferenceTypeFirstWithNameMatchingConfigurationKeyOrDefault( + new ValueOfConfigurationKeyOrNull(Guice.createInjector(new AbstractModule() { + + @Override + protected void configure() { + bindConstant().annotatedWith(Names.named("foo")).to(".*mary.*"); + } + + })), "foo", Predicates. alwaysTrue()).apply(ImmutableList. of(reference1, + reference2)), reference2); + + } + + @Test(expectedExceptions = NoSuchElementException.class) + public void testThrowsNoSuchElementWhenNoneMatchConfigurationKey() { + ReferenceType reference1 = new ReferenceTypeImpl("travis tritt", null, null); + ReferenceType reference2 = new ReferenceTypeImpl("hail mary", null, null); + + new OnlyReferenceTypeFirstWithNameMatchingConfigurationKeyOrDefault(new ValueOfConfigurationKeyOrNull( + Guice.createInjector(new AbstractModule() { + + @Override + protected void configure() { + bindConstant().annotatedWith(Names.named("foo")).to(".*happy.*"); + } + + })), "foo", Predicates. alwaysTrue()).apply(ImmutableList. of(reference1, + reference2)); + + } +} diff --git a/providers/bluelock-vcdirector/src/main/java/org/jclouds/vcloud/bluelock/BluelockVCloudDirectorPropertiesBuilder.java b/providers/bluelock-vcdirector/src/main/java/org/jclouds/vcloud/bluelock/BluelockVCloudDirectorPropertiesBuilder.java index d16116f559..8294a674a7 100644 --- a/providers/bluelock-vcdirector/src/main/java/org/jclouds/vcloud/bluelock/BluelockVCloudDirectorPropertiesBuilder.java +++ b/providers/bluelock-vcdirector/src/main/java/org/jclouds/vcloud/bluelock/BluelockVCloudDirectorPropertiesBuilder.java @@ -40,7 +40,7 @@ public class BluelockVCloudDirectorPropertiesBuilder extends VCloudPropertiesBui Properties properties = super.defaultProperties(); properties.setProperty(PROPERTY_ISO3166_CODES, "US-IN"); properties.setProperty(PROPERTY_ENDPOINT, "https://vcenterprise.bluelock.com/api"); - properties.setProperty(PROPERTY_VCLOUD_DEFAULT_NETWORK, "internet01"); + properties.setProperty(PROPERTY_VCLOUD_DEFAULT_NETWORK, "internet01-.*"); return properties; } diff --git a/providers/bluelock-vcloud-vcenterprise/src/main/java/org/jclouds/bluelock/vcloud/vcenterprise/BluelockVCloudEnterprisePropertiesBuilder.java b/providers/bluelock-vcloud-vcenterprise/src/main/java/org/jclouds/bluelock/vcloud/vcenterprise/BluelockVCloudEnterprisePropertiesBuilder.java index 5ee26e8d44..79845fae4d 100644 --- a/providers/bluelock-vcloud-vcenterprise/src/main/java/org/jclouds/bluelock/vcloud/vcenterprise/BluelockVCloudEnterprisePropertiesBuilder.java +++ b/providers/bluelock-vcloud-vcenterprise/src/main/java/org/jclouds/bluelock/vcloud/vcenterprise/BluelockVCloudEnterprisePropertiesBuilder.java @@ -37,7 +37,7 @@ public class BluelockVCloudEnterprisePropertiesBuilder extends VCloudPropertiesB Properties properties = super.defaultProperties(); properties.setProperty(PROPERTY_ISO3166_CODES, "US-IN"); properties.setProperty(PROPERTY_ENDPOINT, "https://vcenterprise.bluelock.com/api"); - properties.setProperty(PROPERTY_VCLOUD_DEFAULT_NETWORK, "internet01"); + properties.setProperty(PROPERTY_VCLOUD_DEFAULT_NETWORK, "internet01-.*"); return properties; } diff --git a/providers/bluelock-vcloud-zone01/src/main/java/org/jclouds/bluelock/vcloud/zone01/BluelockVCloudZone01PropertiesBuilder.java b/providers/bluelock-vcloud-zone01/src/main/java/org/jclouds/bluelock/vcloud/zone01/BluelockVCloudZone01PropertiesBuilder.java index 779b1fdf85..493881b105 100644 --- a/providers/bluelock-vcloud-zone01/src/main/java/org/jclouds/bluelock/vcloud/zone01/BluelockVCloudZone01PropertiesBuilder.java +++ b/providers/bluelock-vcloud-zone01/src/main/java/org/jclouds/bluelock/vcloud/zone01/BluelockVCloudZone01PropertiesBuilder.java @@ -37,7 +37,7 @@ public class BluelockVCloudZone01PropertiesBuilder extends VCloudPropertiesBuild Properties properties = super.defaultProperties(); properties.setProperty(PROPERTY_ISO3166_CODES, "US-IN"); properties.setProperty(PROPERTY_ENDPOINT, "https://zone01.bluelock.com/api"); - properties.setProperty(PROPERTY_VCLOUD_DEFAULT_NETWORK, "internet01"); + properties.setProperty(PROPERTY_VCLOUD_DEFAULT_NETWORK, "internet01-.*"); return properties; } diff --git a/providers/trmk-ecloud/pom.xml b/providers/trmk-ecloud/pom.xml index 0d6fbca333..4e5ac83b73 100644 --- a/providers/trmk-ecloud/pom.xml +++ b/providers/trmk-ecloud/pom.xml @@ -36,6 +36,7 @@ https://services.enterprisecloud.terremark.com/api + MIA 0.8b-ext2.8 FIXME FIXME @@ -141,6 +142,10 @@ test.trmk-ecloud.credential ${test.trmk-ecloud.credential} + + test.trmk-ecloud.datacenter + ${test.trmk-ecloud.datacenter} + diff --git a/providers/trmk-ecloud/src/main/java/org/jclouds/terremark/ecloud/functions/OrgURIToDataCentersListEndpoint.java b/providers/trmk-ecloud/src/main/java/org/jclouds/terremark/ecloud/functions/OrgURIToDataCentersListEndpoint.java index 97c9b2281f..38aa6658e8 100644 --- a/providers/trmk-ecloud/src/main/java/org/jclouds/terremark/ecloud/functions/OrgURIToDataCentersListEndpoint.java +++ b/providers/trmk-ecloud/src/main/java/org/jclouds/terremark/ecloud/functions/OrgURIToDataCentersListEndpoint.java @@ -26,6 +26,7 @@ import javax.inject.Singleton; import org.jclouds.terremark.ecloud.domain.TerremarkECloudOrg; import org.jclouds.vcloud.domain.Org; +import org.jclouds.vcloud.domain.ReferenceType; import org.jclouds.vcloud.terremark.domain.TerremarkOrg; import org.jclouds.vcloud.terremark.functions.OrgURIToEndpoint; @@ -40,7 +41,7 @@ import com.google.common.base.Supplier; public class OrgURIToDataCentersListEndpoint extends OrgURIToEndpoint implements Function { @Inject public OrgURIToDataCentersListEndpoint(Supplier> orgMap, - @org.jclouds.vcloud.endpoints.Org URI defaultUri) { + @org.jclouds.vcloud.endpoints.Org ReferenceType defaultUri) { super(orgMap, defaultUri); } diff --git a/providers/trmk-ecloud/src/main/java/org/jclouds/terremark/ecloud/functions/OrgURIToTagsListEndpoint.java b/providers/trmk-ecloud/src/main/java/org/jclouds/terremark/ecloud/functions/OrgURIToTagsListEndpoint.java index aeb35daffe..b8e1b30edf 100644 --- a/providers/trmk-ecloud/src/main/java/org/jclouds/terremark/ecloud/functions/OrgURIToTagsListEndpoint.java +++ b/providers/trmk-ecloud/src/main/java/org/jclouds/terremark/ecloud/functions/OrgURIToTagsListEndpoint.java @@ -26,6 +26,7 @@ import javax.inject.Singleton; import org.jclouds.terremark.ecloud.domain.TerremarkECloudOrg; import org.jclouds.vcloud.domain.Org; +import org.jclouds.vcloud.domain.ReferenceType; import org.jclouds.vcloud.terremark.domain.TerremarkOrg; import org.jclouds.vcloud.terremark.functions.OrgURIToEndpoint; @@ -40,7 +41,7 @@ import com.google.common.base.Supplier; public class OrgURIToTagsListEndpoint extends OrgURIToEndpoint implements Function { @Inject public OrgURIToTagsListEndpoint(Supplier> orgMap, - @org.jclouds.vcloud.endpoints.Org URI defaultUri) { + @org.jclouds.vcloud.endpoints.Org ReferenceType defaultUri) { super(orgMap, defaultUri); } diff --git a/providers/trmk-ecloud/src/main/java/org/jclouds/vcloud/terremark/TerremarkECloudAsyncClient.java b/providers/trmk-ecloud/src/main/java/org/jclouds/vcloud/terremark/TerremarkECloudAsyncClient.java index 6e1c982718..6d0df667e0 100644 --- a/providers/trmk-ecloud/src/main/java/org/jclouds/vcloud/terremark/TerremarkECloudAsyncClient.java +++ b/providers/trmk-ecloud/src/main/java/org/jclouds/vcloud/terremark/TerremarkECloudAsyncClient.java @@ -76,7 +76,7 @@ import org.jclouds.vcloud.terremark.xml.IpAddressesHandler; import org.jclouds.vcloud.terremark.xml.KeyPairByNameHandler; import org.jclouds.vcloud.terremark.xml.KeyPairHandler; import org.jclouds.vcloud.terremark.xml.KeyPairsHandler; -import org.jclouds.vcloud.terremark.xml.PublicIpAddressesHandler; +import org.jclouds.vcloud.terremark.xml.PublicIpAddressHandler; import org.jclouds.vcloud.terremark.xml.TerremarkNetworkHandler; import org.jclouds.vcloud.terremark.xml.TerremarkOrgNetworkFromTerremarkVCloudExpressNetworkHandler; import org.jclouds.vcloud.terremark.xml.VAppExtendedInfoHandler; @@ -137,8 +137,8 @@ public interface TerremarkECloudAsyncClient extends TerremarkVCloudAsyncClient { */ @POST @Consumes(PUBLICIP_XML) - @XMLResponseParser(PublicIpAddressesHandler.class) - @ExceptionParser(ReturnVoidOnNotFoundOr404.class) + @XMLResponseParser(PublicIpAddressHandler.class) + @ExceptionParser(ReturnNullOnNotFoundOr404.class) ListenableFuture activatePublicIpInVDC( @EndpointParam(parser = VDCURIToPublicIPsEndpoint.class) URI vDCId); diff --git a/providers/trmk-ecloud/src/main/java/org/jclouds/vcloud/terremark/config/TerremarkECloudRestClientModule.java b/providers/trmk-ecloud/src/main/java/org/jclouds/vcloud/terremark/config/TerremarkECloudRestClientModule.java index 3244de1357..a79b561462 100644 --- a/providers/trmk-ecloud/src/main/java/org/jclouds/vcloud/terremark/config/TerremarkECloudRestClientModule.java +++ b/providers/trmk-ecloud/src/main/java/org/jclouds/vcloud/terremark/config/TerremarkECloudRestClientModule.java @@ -20,21 +20,20 @@ package org.jclouds.vcloud.terremark.config; import static com.google.common.base.Preconditions.checkNotNull; -import java.net.URI; import java.util.Map; -import java.util.NoSuchElementException; +import javax.inject.Inject; import javax.inject.Singleton; import org.jclouds.http.RequiresHttp; import org.jclouds.rest.ConfiguresRestClient; -import org.jclouds.rest.ResourceNotFoundException; import org.jclouds.terremark.ecloud.features.DataCenterOperationsAsyncClient; import org.jclouds.terremark.ecloud.features.DataCenterOperationsClient; import org.jclouds.terremark.ecloud.features.TagOperationsAsyncClient; import org.jclouds.terremark.ecloud.features.TagOperationsClient; import org.jclouds.vcloud.VCloudExpressAsyncClient; import org.jclouds.vcloud.VCloudExpressClient; +import org.jclouds.vcloud.config.DefaultVCloudReferencesModule; import org.jclouds.vcloud.domain.ReferenceType; import org.jclouds.vcloud.terremark.TerremarkECloudAsyncClient; import org.jclouds.vcloud.terremark.TerremarkECloudClient; @@ -45,24 +44,24 @@ import org.jclouds.vcloud.terremark.domain.TerremarkOrgNetwork; import com.google.common.base.Predicate; import com.google.common.collect.ImmutableMap; -import com.google.common.collect.Iterables; import com.google.inject.Injector; import com.google.inject.Provides; /** - * Configures the VCloud authentication service connection, including logging and http transport. + * Configures the VCloud authentication service connection, including logging + * and http transport. * * @author Adrian Cole */ @RequiresHttp @ConfiguresRestClient public class TerremarkECloudRestClientModule extends - TerremarkRestClientModule { + TerremarkRestClientModule { public static final Map, Class> DELEGATE_MAP = ImmutableMap., Class> builder()// - .put(DataCenterOperationsClient.class, DataCenterOperationsAsyncClient.class)// - .put(TagOperationsClient.class, TagOperationsAsyncClient.class)// - .build(); + .put(DataCenterOperationsClient.class, DataCenterOperationsAsyncClient.class)// + .put(TagOperationsClient.class, TagOperationsAsyncClient.class)// + .build(); public TerremarkECloudRestClientModule() { super(TerremarkECloudClient.class, TerremarkECloudAsyncClient.class, DELEGATE_MAP); @@ -92,36 +91,51 @@ public class TerremarkECloudRestClientModule extends return in; } - @Override - protected URI findDefaultNetworkForVDC(org.jclouds.vcloud.domain.VDC vDC, Map networks, - final Injector injector) { - // TODO FIXME XXX: In Terremark Enterprise environment with multiple VDC's this does not - // work well. - // Each VDC will have differnt network subnets. So we cannot assume the default VDC's - // networks will - // work with non-default VDC's. So make PROPERTY_VCLOUD_DEFAULT_NETWORK optional. If - // this property - // is not set, they are expected to add NetworkConfig to the options when launching a - // server. - logger.warn("default network for vdc %s not set", vDC.getName()); - try { - return Iterables.find(networks.values(), new Predicate() { + @Singleton + public static class IsDMZNetwork implements Predicate { + private final TerremarkECloudClient client; - @Override - public boolean apply(ReferenceType input) { - TerremarkOrgNetwork network = injector.getInstance(TerremarkECloudClient.class).getNetwork( - input.getHref()); - TerremarkNetwork terremarkNetwork = injector.getInstance(TerremarkECloudClient.class) - .getTerremarkNetwork( - checkNotNull(checkNotNull(network, "network at: " + input).getNetworkExtension(), - "network extension for: " + input).getHref()); - return checkNotNull(terremarkNetwork, "terremark network extension at: " + network.getNetworkExtension()) - .getNetworkType() == TerremarkNetwork.Type.DMZ; - } + @Inject + public IsDMZNetwork(TerremarkECloudClient client) { + this.client = client; + } - }).getHref(); - } catch (NoSuchElementException e) { - throw new ResourceNotFoundException("no dmz networks in vdc " + vDC.getName() + ": " + networks); + @Override + public boolean apply(ReferenceType arg0) { + // TODO FIXME XXX: In Terremark Enterprise environment with multiple + // VDC's + // this does not + // work well. + // Each VDC will have differnt network subnets. So we cannot assume the + // default VDC's + // networks will + // work with non-default VDC's. So make PROPERTY_VCLOUD_DEFAULT_NETWORK + // optional. If + // this property + // is not set, they are expected to add NetworkConfig to the options + // when + // launching a + // server. + TerremarkOrgNetwork orgNetwork = client.getNetwork(arg0.getHref()); + TerremarkNetwork terremarkNetwork = client.getTerremarkNetwork(checkNotNull( + checkNotNull(orgNetwork, "network at: " + arg0).getNetworkExtension(), "network extension for: " + arg0) + .getHref()); + return checkNotNull(terremarkNetwork, "terremark network extension at: " + orgNetwork.getNetworkExtension()) + .getNetworkType() == TerremarkNetwork.Type.DMZ; } } + + @Override + protected void installDefaultVCloudEndpointsModule() { + install(new DefaultVCloudReferencesModule() { + + @Override + protected Predicate provideDefaultNetworkSelector(Injector i) { + return i.getInstance(IsDMZNetwork.class); + } + + }); + + } + } diff --git a/providers/trmk-ecloud/src/main/java/org/jclouds/vcloud/terremark/suppliers/TerremarkECloudInternetServiceAndPublicIpAddressSupplier.java b/providers/trmk-ecloud/src/main/java/org/jclouds/vcloud/terremark/suppliers/TerremarkECloudInternetServiceAndPublicIpAddressSupplier.java index 4cf89bcfa8..dcc77ce2a5 100644 --- a/providers/trmk-ecloud/src/main/java/org/jclouds/vcloud/terremark/suppliers/TerremarkECloudInternetServiceAndPublicIpAddressSupplier.java +++ b/providers/trmk-ecloud/src/main/java/org/jclouds/vcloud/terremark/suppliers/TerremarkECloudInternetServiceAndPublicIpAddressSupplier.java @@ -61,7 +61,7 @@ public class TerremarkECloudInternetServiceAndPublicIpAddressSupplier implements @Override public Entry getNewInternetServiceAndIp(VCloudExpressVApp vApp, int port, Protocol protocol) { - logger.debug(">> creating InternetService in vDC %s:%s:%d", vApp.getVDC().getName(), protocol, port); + logger.debug(">> creating InternetService in vDC %s:%s:%d", vApp.getVDC().getHref(), protocol, port); InternetService is = null; PublicIpAddress ip = null; try { diff --git a/providers/trmk-ecloud/src/test/java/org/jclouds/terremark/ecloud/BaseTerremarkECloudAsyncClientTest.java b/providers/trmk-ecloud/src/test/java/org/jclouds/terremark/ecloud/BaseTerremarkECloudAsyncClientTest.java index 097fa449c3..00761a8bd4 100644 --- a/providers/trmk-ecloud/src/test/java/org/jclouds/terremark/ecloud/BaseTerremarkECloudAsyncClientTest.java +++ b/providers/trmk-ecloud/src/test/java/org/jclouds/terremark/ecloud/BaseTerremarkECloudAsyncClientTest.java @@ -18,13 +18,13 @@ */ package org.jclouds.terremark.ecloud; -import static org.jclouds.Constants.PROPERTY_API_VERSION; -import static org.jclouds.Constants.PROPERTY_IDENTITY; +import static org.jclouds.Constants.PROPERTY_SESSION_INTERVAL; import static org.testng.Assert.assertEquals; import java.net.URI; import java.util.Map; import java.util.Properties; +import java.util.concurrent.atomic.AtomicReference; import javax.inject.Inject; import javax.inject.Named; @@ -32,36 +32,36 @@ import javax.inject.Singleton; import org.jclouds.http.HttpRequest; import org.jclouds.http.RequiresHttp; +import org.jclouds.rest.AuthorizationException; import org.jclouds.rest.ConfiguresRestClient; import org.jclouds.rest.RestClientTest; import org.jclouds.rest.RestContextFactory; import org.jclouds.rest.RestContextSpec; import org.jclouds.terremark.ecloud.domain.internal.TerremarkECloudOrgImpl; -import org.jclouds.vcloud.CommonVCloudClient; -import org.jclouds.vcloud.VCloudExpressAsyncClientTest.VCloudRestClientModuleExtension.TestOrgCatalogItemSupplier; -import org.jclouds.vcloud.VCloudExpressAsyncClientTest.VCloudRestClientModuleExtension.TestOrgCatalogSupplier; +import org.jclouds.vcloud.VCloudExpressLoginAsyncClient; +import org.jclouds.vcloud.VCloudMediaType; import org.jclouds.vcloud.VCloudVersionsAsyncClient; -import org.jclouds.vcloud.config.CommonVCloudRestClientModule.OrgVDCSupplier; import org.jclouds.vcloud.domain.AllocationModel; -import org.jclouds.vcloud.domain.Capacity; import org.jclouds.vcloud.domain.Org; import org.jclouds.vcloud.domain.ReferenceType; import org.jclouds.vcloud.domain.Task; import org.jclouds.vcloud.domain.VCloudSession; +import org.jclouds.vcloud.domain.VDC; import org.jclouds.vcloud.domain.VDCStatus; +import org.jclouds.vcloud.domain.internal.CatalogImpl; +import org.jclouds.vcloud.domain.internal.CatalogItemImpl; import org.jclouds.vcloud.domain.internal.ReferenceTypeImpl; import org.jclouds.vcloud.filters.SetVCloudTokenCookie; import org.jclouds.vcloud.terremark.TerremarkECloudMediaType; -import org.jclouds.vcloud.terremark.TerremarkVCloudMediaType; import org.jclouds.vcloud.terremark.config.TerremarkECloudRestClientModule; import org.jclouds.vcloud.terremark.domain.internal.TerremarkVDCImpl; -import com.google.common.base.Function; import com.google.common.base.Supplier; +import com.google.common.base.Suppliers; +import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Maps; -import com.google.inject.Injector; +import com.google.inject.AbstractModule; import com.google.inject.Module; /** @@ -69,128 +69,6 @@ import com.google.inject.Module; */ public abstract class BaseTerremarkECloudAsyncClientTest extends RestClientTest { - @RequiresHttp - @ConfiguresRestClient - protected static class TerremarkVCloudRestClientModuleExtension extends TerremarkECloudRestClientModule { - @Override - protected URI provideAuthenticationURI(VCloudVersionsAsyncClient versionService, - @Named(PROPERTY_API_VERSION) String version) { - return URI.create("https://vcloud/login"); - } - - @Override - protected void configure() { - super.configure(); - bind(OrgNameToKeysListSupplier.class).to(TestOrgNameToKeysListSupplier.class); - bind(OrgMapSupplier.class).to(TestTerremarkOrgMapSupplier.class); - bind(OrgCatalogSupplier.class).to(TestOrgCatalogSupplier.class); - bind(OrgCatalogItemSupplier.class).to(TestOrgCatalogItemSupplier.class); - bind(OrgVDCSupplier.class).to(TestTerremarkOrgVDCSupplier.class); - } - - @Singleton - public static class TestOrgNameToKeysListSupplier extends OrgNameToKeysListSupplier { - @Inject - protected TestOrgNameToKeysListSupplier(Supplier sessionSupplier) { - super(sessionSupplier, null); - } - - @Override - public Map get() { - return Maps.transformValues(sessionSupplier.get().getOrgs(), new Function() { - - @Override - public ReferenceType apply(ReferenceType from) { - return new ReferenceTypeImpl(from.getName(), TerremarkECloudMediaType.KEYSLIST_XML, URI.create(from - .getHref().toASCIIString() + "/keysList")); - } - }); - } - } - - @Singleton - public static class TestTerremarkOrgMapSupplier extends OrgMapSupplier { - @Inject - protected TestTerremarkOrgMapSupplier() { - super(null, null); - } - - @Override - public Map get() { - return ImmutableMap. of( - "org", - new TerremarkECloudOrgImpl("org", null, - URI.create("https://vcloud.safesecureweb.com/api/v0.8/org/1"), null, ImmutableMap - . of( - "catalog", - new ReferenceTypeImpl("catalog", TerremarkECloudMediaType.CATALOG_XML, URI - .create("https://vcloud.safesecureweb.com/api/v0.8/catalog/1"))), - ImmutableMap. of( - "vdc", - new ReferenceTypeImpl("vdc", TerremarkECloudMediaType.VDC_XML, URI - .create("https://vcloud.safesecureweb.com/api/v0.8/vdc/1"))), ImmutableMap - . of(), ImmutableMap. of( - "tasksList", - new ReferenceTypeImpl("tasksList", TerremarkECloudMediaType.TASKSLIST_XML, URI - .create("https://vcloud.safesecureweb.com/api/v0.8/tasksList/1"))), - new ReferenceTypeImpl("keysList", TerremarkECloudMediaType.KEYSLIST_XML, URI - .create("https://vcloud.safesecureweb.com/api/v0.8/keysList/1")), new ReferenceTypeImpl( - "deviceTags", TerremarkECloudMediaType.TAGSLISTLIST_XML, URI - .create("https://vcloud.safesecureweb.com/api/v0.8/deviceTags/1")), - new ReferenceTypeImpl("vappCatalog", TerremarkECloudMediaType.VAPPCATALOGLIST_XML, URI - .create("https://vcloud.safesecureweb.com/api/v0.8/vappCatalog/1")), - new ReferenceTypeImpl("dataCentersList", TerremarkECloudMediaType.DATACENTERSLIST_XML, URI - .create("https://vcloud.safesecureweb.com/api/v0.8/datacentersList/1")))); - } - } - - @Override - protected URI provideOrg(@org.jclouds.vcloud.endpoints.Org Iterable orgs) { - return URI.create("https://org"); - } - - @Override - protected String provideOrgName(@org.jclouds.vcloud.endpoints.Org Iterable orgs) { - return "org"; - } - - @Override - protected URI provideCatalog(Org org, @Named(PROPERTY_IDENTITY) String user, WriteableCatalog write) { - return URI.create("https://catalog"); - } - - @Override - protected Org provideOrg(CommonVCloudClient discovery) { - return null; - } - - @Override - protected Iterable provideOrgs(Supplier cache, String user) { - return null; - } - - @Override - protected URI provideDefaultTasksList(Org org) { - return URI.create("https://taskslist"); - } - - @Override - protected URI provideDefaultVDC(Org org, @org.jclouds.vcloud.endpoints.VDC String defaultVDC) { - return URI.create("https://vdc/1"); - } - - @Override - protected String provideDefaultVDCName( - @org.jclouds.vcloud.endpoints.VDC Supplier> vDCtoOrgSupplier) { - return "vdc"; - } - - @Override - protected URI provideDefaultNetwork(URI vdc, Injector injector) { - return URI.create("https://vcloud.safesecureweb.com/network/1990"); - } - } - @Override protected void checkFilters(HttpRequest request) { assertEquals(request.getFilters().size(), 1); @@ -199,7 +77,7 @@ public abstract class BaseTerremarkECloudAsyncClientTest extends RestClientTe @Override protected Module createModule() { - return new TerremarkVCloudRestClientModuleExtension(); + return new TerremarkECloudRestClientModuleExtension(); } @Override @@ -207,37 +85,187 @@ public abstract class BaseTerremarkECloudAsyncClientTest extends RestClientTe return new RestContextFactory().createContextSpec("trmk-ecloud", "identity", "credential", new Properties()); } - @Singleton - public static class TestTerremarkOrgVDCSupplier extends OrgVDCSupplier { - @Inject - protected TestTerremarkOrgVDCSupplier() { - super(null, null); + protected static final ReferenceTypeImpl ORG_REF = new ReferenceTypeImpl("org", VCloudMediaType.ORG_XML, + URI.create("https://vcloud.safesecureweb.com/api/v0.8/org/1")); + + protected static final ReferenceTypeImpl CATALOG_REF = new ReferenceTypeImpl("catalog", VCloudMediaType.CATALOG_XML, + URI.create("https://vcloud.safesecureweb.com/api/v0.8/catalog/1")); + + protected static final ReferenceTypeImpl TASKSLIST_REF = new ReferenceTypeImpl("tasksList", + VCloudMediaType.TASKSLIST_XML, URI.create("https://vcloud.safesecureweb.com/api/v0.8/tasksList/1")); + + protected static final ReferenceTypeImpl VDC_REF = new ReferenceTypeImpl("vdc", VCloudMediaType.VDC_XML, + URI.create("https://vcloud.safesecureweb.com/api/v0.8/vdc/1")); + + protected static final ReferenceTypeImpl KEYSLIST_REF = new ReferenceTypeImpl("keysList", + TerremarkECloudMediaType.KEYSLIST_XML, URI.create("https://vcloud.safesecureweb.com/api/v0.8/keysList/1")); + protected static final ReferenceTypeImpl TAGSLIST_REF = new ReferenceTypeImpl("deviceTags", + TerremarkECloudMediaType.TAGSLISTLIST_XML, + URI.create("https://vcloud.safesecureweb.com/api/v0.8/deviceTags/1")); + protected static final ReferenceTypeImpl VAPPCATALOGLIST_REF = new ReferenceTypeImpl("vappCatalog", + TerremarkECloudMediaType.VAPPCATALOGLIST_XML, + URI.create("https://vcloud.safesecureweb.com/api/v0.8/vappCatalog/1")); + protected static final ReferenceTypeImpl DATACENTERSLIST_REF = new ReferenceTypeImpl("dataCentersList", + TerremarkECloudMediaType.DATACENTERSLIST_XML, + URI.create("https://vcloud.safesecureweb.com/api/v0.8/datacentersList/1")); + protected static final ReferenceTypeImpl NETWORK_REF = new ReferenceTypeImpl("network", VCloudMediaType.NETWORK_XML, + URI.create("https://vcloud.safesecureweb.com/network/1990")); + + protected static final ReferenceTypeImpl PUBLICIPS_REF = new ReferenceTypeImpl("publicIps", + TerremarkECloudMediaType.PUBLICIPSLIST_XML, + URI.create("https://vcloud.safesecureweb.com/api/v0.8/publicIps/1")); + + protected static final ReferenceTypeImpl INTERNETSERVICES_REF = new ReferenceTypeImpl("internetServices", + TerremarkECloudMediaType.INTERNETSERVICESLIST_XML, + URI.create("https://vcloud.safesecureweb.com/api/v0.8/internetServices/1")); + + protected static final Org ORG = new TerremarkECloudOrgImpl(ORG_REF.getName(), ORG_REF.getType(), ORG_REF.getHref(), + "org", ImmutableMap. of(CATALOG_REF.getName(), CATALOG_REF), + ImmutableMap. of(VDC_REF.getName(), VDC_REF), ImmutableMap. of( + NETWORK_REF.getName(), NETWORK_REF), ImmutableMap. of(TASKSLIST_REF.getName(), + TASKSLIST_REF), KEYSLIST_REF, TAGSLIST_REF, VAPPCATALOGLIST_REF, DATACENTERSLIST_REF); + + protected static final VDC VDC = new TerremarkVDCImpl(VDC_REF.getName(), VDC_REF.getType(), VDC_REF.getHref(), + VDCStatus.READY, null, "description", ImmutableSet. of(), AllocationModel.ALLOCATION_POOL, null, null, + null, ImmutableMap. of( + "vapp", + new ReferenceTypeImpl("vapp", "application/vnd.vmware.vcloud.vApp+xml", URI + .create("https://vcloud.safesecureweb.com/api/v0.8/vApp/188849-1")), + "network", + new ReferenceTypeImpl("network", "application/vnd.vmware.vcloud.vAppTemplate+xml", URI + .create("https://vcloud.safesecureweb.com/api/v0.8/vdcItem/2"))), + ImmutableMap. of(NETWORK_REF.getName(), NETWORK_REF), 0, 0, 0, false, CATALOG_REF, + PUBLICIPS_REF, INTERNETSERVICES_REF); + + @RequiresHttp + @ConfiguresRestClient + protected static class TerremarkECloudRestClientModuleExtension extends TerremarkECloudRestClientModule { + + @Override + protected URI provideAuthenticationURI(VCloudVersionsAsyncClient versionService, String version) { + return URI.create("https://vcloud.safesecureweb.com/api/v0.8/login"); } @Override - public Map> get() { - return ImmutableMap.> of("org", - - ImmutableMap. of( - "vdc", - new TerremarkVDCImpl("vdc", null, URI.create("https://vcloud.safesecureweb.com/api/v0.8/vdc/1"), - VDCStatus.READY, null, "description", ImmutableSet. of(), AllocationModel.UNRECOGNIZED, - new Capacity("MB", 0, 0, 0, 0), new Capacity("MB", 0, 0, 0, 0), new Capacity("MB", 0, 0, 0, 0), - ImmutableMap. of( - "vapp", - new ReferenceTypeImpl("vapp", "application/vnd.vmware.vcloud.vApp+xml", URI - .create("https://vcloud.safesecureweb.com/api/v0.8/vApp/188849-1")), - "network", - new ReferenceTypeImpl("network", "application/vnd.vmware.vcloud.vAppTemplate+xml", URI - .create("https://vcloud.safesecureweb.com/api/v0.8/vdcItem/2"))), ImmutableMap - . of(), 0, 0, 0, false, new ReferenceTypeImpl("catalog", - TerremarkVCloudMediaType.CATALOG_XML, URI - .create("https://vcloud.safesecureweb.com/api/v0.8/catalog/1")), - new ReferenceTypeImpl("publicIps", TerremarkVCloudMediaType.PUBLICIPSLIST_XML, URI - .create("https://vcloud.safesecureweb.com/api/v0.8/publicIps/1")), new ReferenceTypeImpl( - "internetServices", TerremarkVCloudMediaType.INTERNETSERVICESLIST_XML, URI - .create("https://vcloud.safesecureweb.com/api/v0.8/internetServices/1"))))); + protected Org provideOrg(Supplier> orgSupplier, + @org.jclouds.vcloud.endpoints.Org ReferenceType defaultOrg) { + return ORG; } - } + @Override + protected void installDefaultVCloudEndpointsModule() { + install(new AbstractModule() { + + @Override + protected void configure() { + bind(ReferenceType.class).annotatedWith(org.jclouds.vcloud.endpoints.Org.class).toInstance(ORG_REF); + bind(ReferenceType.class).annotatedWith(org.jclouds.vcloud.endpoints.Catalog.class).toInstance( + CATALOG_REF); + bind(ReferenceType.class).annotatedWith(org.jclouds.vcloud.endpoints.TasksList.class).toInstance( + TASKSLIST_REF); + bind(ReferenceType.class).annotatedWith(org.jclouds.vcloud.endpoints.VDC.class).toInstance(VDC_REF); + bind(ReferenceType.class).annotatedWith(org.jclouds.vcloud.endpoints.Network.class).toInstance( + NETWORK_REF); + } + + }); + } + + @Override + protected Supplier provideVCloudTokenCache(@Named(PROPERTY_SESSION_INTERVAL) long seconds, + AtomicReference authException, VCloudExpressLoginAsyncClient login) { + return Suppliers. ofInstance(new VCloudSession() { + + @Override + public Map getOrgs() { + return ImmutableMap. of(ORG_REF.getName(), ORG_REF); + } + + @Override + public String getVCloudToken() { + return "token"; + } + + }); + + } + + @Override + protected void configure() { + super.configure(); + bind(OrgMapSupplier.class).to(TestOrgMapSupplier.class); + bind(OrgCatalogSupplier.class).to(TestOrgCatalogSupplier.class); + bind(OrgCatalogItemSupplier.class).to(TestOrgCatalogItemSupplier.class); + } + + @Override + protected Supplier>> provideOrgVDCSupplierCache( + @Named(PROPERTY_SESSION_INTERVAL) long seconds, AtomicReference authException, + OrgVDCSupplier supplier) { + return Suppliers.>> ofInstance(ImmutableMap + .> of(ORG_REF.getName(), + ImmutableMap. of(VDC.getName(), VDC))); + } + + @Singleton + public static class TestOrgMapSupplier extends OrgMapSupplier { + + @Inject + protected TestOrgMapSupplier() { + super(null, null); + } + + @Override + public Map get() { + return ImmutableMap. of(ORG.getName(), ORG); + } + } + + @Singleton + public static class TestOrgCatalogSupplier extends OrgCatalogSupplier { + @Inject + protected TestOrgCatalogSupplier() { + super(null, null); + } + + @Override + public Map> get() { + return ImmutableMap.> of( + ORG_REF.getName(), ImmutableMap. of( + CATALOG_REF.getName(), + new CatalogImpl(CATALOG_REF.getName(), CATALOG_REF.getType(), CATALOG_REF.getHref(), null, + "description", ImmutableMap. of( + "item", + new ReferenceTypeImpl("item", "application/vnd.vmware.vcloud.catalogItem+xml", URI + .create("https://vcloud.safesecureweb.com/api/v0.8/catalogItem/1")), + "template", + new ReferenceTypeImpl("template", "application/vnd.vmware.vcloud.vAppTemplate+xml", + URI.create("https://vcloud.safesecureweb.com/api/v0.8/catalogItem/2"))), + ImmutableList. of(), true, false))); + } + } + + @Singleton + public static class TestOrgCatalogItemSupplier extends OrgCatalogItemSupplier { + protected TestOrgCatalogItemSupplier() { + super(null, null); + } + + @Override + public Map>> get() { + return ImmutableMap.>> of( + ORG_REF.getName(), ImmutableMap + .> of(CATALOG_REF + .getName(), ImmutableMap. of( + "template", + new CatalogItemImpl("template", URI + .create("https://vcloud.safesecureweb.com/api/v0.8/catalogItem/2"), "description", + new ReferenceTypeImpl("template", "application/vnd.vmware.vcloud.vAppTemplate+xml", + URI.create("https://vcloud.safesecureweb.com/api/v0.8/vAppTemplate/2")), + ImmutableMap. of())))); + + } + } + + } } \ No newline at end of file diff --git a/providers/trmk-ecloud/src/test/java/org/jclouds/terremark/ecloud/BaseTerremarkECloudClientLiveTest.java b/providers/trmk-ecloud/src/test/java/org/jclouds/terremark/ecloud/BaseTerremarkECloudClientLiveTest.java index 7da1548044..55d0f1280a 100644 --- a/providers/trmk-ecloud/src/test/java/org/jclouds/terremark/ecloud/BaseTerremarkECloudClientLiveTest.java +++ b/providers/trmk-ecloud/src/test/java/org/jclouds/terremark/ecloud/BaseTerremarkECloudClientLiveTest.java @@ -18,6 +18,9 @@ */ package org.jclouds.terremark.ecloud; +import java.util.Properties; + +import org.jclouds.vcloud.reference.VCloudConstants; import org.jclouds.vcloud.terremark.BaseTerremarkClientLiveTest; import org.jclouds.vcloud.terremark.TerremarkECloudClient; import org.testng.annotations.Test; @@ -27,5 +30,11 @@ import org.testng.annotations.Test; */ @Test(groups = "live", enabled = true, singleThreaded = true) public class BaseTerremarkECloudClientLiveTest extends BaseTerremarkClientLiveTest { - + @Override + protected Properties setupProperties() { + Properties props = super.setupProperties(); + props.setProperty(VCloudConstants.PROPERTY_VCLOUD_DEFAULT_VDC, + ".* - " + System.getProperty("test.trmk-ecloud.datacenter", "MIA")); + return props; + } } \ No newline at end of file diff --git a/providers/trmk-ecloud/src/test/java/org/jclouds/terremark/ecloud/features/DataCenterOperationsClientLiveTest.java b/providers/trmk-ecloud/src/test/java/org/jclouds/terremark/ecloud/features/DataCenterOperationsClientLiveTest.java index 68a90e8f5f..c0ceed16d4 100644 --- a/providers/trmk-ecloud/src/test/java/org/jclouds/terremark/ecloud/features/DataCenterOperationsClientLiveTest.java +++ b/providers/trmk-ecloud/src/test/java/org/jclouds/terremark/ecloud/features/DataCenterOperationsClientLiveTest.java @@ -33,7 +33,7 @@ import org.testng.annotations.Test; public class DataCenterOperationsClientLiveTest extends BaseTerremarkECloudClientLiveTest { @Test public void testListDataCentersInOrg() throws Exception { - for (ReferenceType response : getApi().listOrgs()) { + for (ReferenceType response : getApi().listOrgs().values()) { TerremarkECloudOrg org = getApi().getOrg(response.getHref()); assertNotNull(response); assertNotNull(response.getName()); diff --git a/providers/trmk-ecloud/src/test/java/org/jclouds/terremark/ecloud/features/TagOperationsClientLiveTest.java b/providers/trmk-ecloud/src/test/java/org/jclouds/terremark/ecloud/features/TagOperationsClientLiveTest.java index b8f537cd49..7560ccb813 100644 --- a/providers/trmk-ecloud/src/test/java/org/jclouds/terremark/ecloud/features/TagOperationsClientLiveTest.java +++ b/providers/trmk-ecloud/src/test/java/org/jclouds/terremark/ecloud/features/TagOperationsClientLiveTest.java @@ -33,7 +33,7 @@ import org.testng.annotations.Test; public class TagOperationsClientLiveTest extends BaseTerremarkECloudClientLiveTest { @Test public void testListTagsInOrg() throws Exception { - for (ReferenceType response : getApi().listOrgs()) { + for (ReferenceType response : getApi().listOrgs().values()) { TerremarkECloudOrg org = getApi().getOrg(response.getHref()); assertNotNull(response); assertNotNull(response.getName()); diff --git a/providers/trmk-ecloud/src/test/java/org/jclouds/vcloud/terremark/TerremarkECloudAsyncClientTest.java b/providers/trmk-ecloud/src/test/java/org/jclouds/vcloud/terremark/TerremarkECloudAsyncClientTest.java index 2bd57577f1..924106ff7d 100644 --- a/providers/trmk-ecloud/src/test/java/org/jclouds/vcloud/terremark/TerremarkECloudAsyncClientTest.java +++ b/providers/trmk-ecloud/src/test/java/org/jclouds/vcloud/terremark/TerremarkECloudAsyncClientTest.java @@ -19,12 +19,12 @@ package org.jclouds.vcloud.terremark; import static org.jclouds.vcloud.terremark.options.AddInternetServiceOptions.Builder.disabled; +import static org.testng.Assert.assertEquals; import java.io.IOException; import java.lang.reflect.Method; import java.net.URI; - import org.jclouds.http.HttpRequest; import org.jclouds.http.functions.ParseSax; import org.jclouds.http.functions.ReleasePayloadAndReturn; @@ -50,7 +50,7 @@ import org.jclouds.vcloud.terremark.xml.KeyPairHandler; import org.jclouds.vcloud.terremark.xml.KeyPairsHandler; import org.jclouds.vcloud.terremark.xml.NodeHandler; import org.jclouds.vcloud.terremark.xml.NodesHandler; -import org.jclouds.vcloud.terremark.xml.PublicIpAddressesHandler; +import org.jclouds.vcloud.terremark.xml.PublicIpAddressHandler; import org.jclouds.vcloud.terremark.xml.TerremarkOrgNetworkFromTerremarkVCloudExpressNetworkHandler; import org.jclouds.vcloud.terremark.xml.TerremarkVDCHandler; import org.jclouds.vcloud.terremark.xml.VAppExtendedInfoHandler; @@ -58,24 +58,30 @@ import org.jclouds.vcloud.xml.VCloudExpressCatalogHandler; import org.jclouds.vcloud.xml.VCloudExpressVAppHandler; import org.testng.annotations.Test; +import com.google.common.collect.ImmutableMap; import com.google.inject.TypeLiteral; - /** * Tests behavior of {@code TerremarkECloudAsyncClient} * * @author Adrian Cole */ -// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire +// NOTE:without testName, this will not call @Before* and fail w/NPE during +// surefire @Test(groups = "unit", singleThreaded = true, testName = "TerremarkECloudAsyncClientTest") public class TerremarkECloudAsyncClientTest extends BaseTerremarkECloudAsyncClientTest { + public void testListOrgs() { + assertEquals(injector.getInstance(TerremarkECloudAsyncClient.class).listOrgs().toString(), + ImmutableMap.of(ORG_REF.getName(), ORG_REF).toString()); + } + @Override protected TypeLiteral> createTypeLiteral() { return new TypeLiteral>() { }; } - + public void testNetwork() throws SecurityException, NoSuchMethodException, IOException { Method method = TerremarkECloudAsyncClient.class.getMethod("getNetwork", URI.class); HttpRequest request = processor.createRequest(method, @@ -219,8 +225,8 @@ public class TerremarkECloudAsyncClientTest extends BaseTerremarkECloudAsyncClie assertPayloadEquals(request, null, null, false); assertResponseParserClassEquals(method, request, ParseSax.class); - assertSaxResponseParserClassEquals(method, PublicIpAddressesHandler.class); - assertExceptionParserClassEquals(method, ReturnVoidOnNotFoundOr404.class); + assertSaxResponseParserClassEquals(method, PublicIpAddressHandler.class); + assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class); checkFilters(request); } diff --git a/providers/trmk-ecloud/src/test/java/org/jclouds/vcloud/terremark/TerremarkECloudClientLiveTest.java b/providers/trmk-ecloud/src/test/java/org/jclouds/vcloud/terremark/TerremarkECloudClientLiveTest.java index df53e98da6..066f95d4b6 100644 --- a/providers/trmk-ecloud/src/test/java/org/jclouds/vcloud/terremark/TerremarkECloudClientLiveTest.java +++ b/providers/trmk-ecloud/src/test/java/org/jclouds/vcloud/terremark/TerremarkECloudClientLiveTest.java @@ -21,11 +21,13 @@ package org.jclouds.vcloud.terremark; import static org.jclouds.vcloud.terremark.options.TerremarkInstantiateVAppTemplateOptions.Builder.processorCount; import java.util.Map.Entry; +import java.util.Properties; import org.jclouds.domain.Credentials; import org.jclouds.net.IPSocket; import org.jclouds.ssh.SshClient; import org.jclouds.vcloud.domain.VCloudExpressVApp; +import org.jclouds.vcloud.reference.VCloudConstants; import org.jclouds.vcloud.terremark.domain.InternetService; import org.jclouds.vcloud.terremark.domain.Protocol; import org.jclouds.vcloud.terremark.domain.PublicIpAddress; @@ -41,6 +43,14 @@ import org.testng.annotations.Test; */ @Test(groups = "live", enabled = true, singleThreaded = true, testName = "TerremarkECloudClientLiveTest") public class TerremarkECloudClientLiveTest extends TerremarkClientLiveTest { + @Override + protected Properties setupProperties() { + Properties props = super.setupProperties(); + props.setProperty(VCloudConstants.PROPERTY_VCLOUD_DEFAULT_VDC, + ".* - " + System.getProperty("test.trmk-ecloud.datacenter", "MIA")); + return props; + } + @BeforeClass void setProvider() { this.provider = "trmk-ecloud"; @@ -61,7 +71,7 @@ public class TerremarkECloudClientLiveTest extends TerremarkClientLiveTest { @Override protected Entry getNewInternetServiceAndIpForSSH(VCloudExpressVApp vApp) { return new TerremarkECloudInternetServiceAndPublicIpAddressSupplier(TerremarkECloudClient.class.cast(tmClient)) - .getNewInternetServiceAndIp(vApp, 22, Protocol.TCP); + .getNewInternetServiceAndIp(vApp, 22, Protocol.TCP); } } diff --git a/providers/trmk-ecloud/src/test/java/org/jclouds/vcloud/terremark/compute/TerremarkECloudComputeServiceLiveTest.java b/providers/trmk-ecloud/src/test/java/org/jclouds/vcloud/terremark/compute/TerremarkECloudComputeServiceLiveTest.java index 951a41815f..f6ed5dc315 100644 --- a/providers/trmk-ecloud/src/test/java/org/jclouds/vcloud/terremark/compute/TerremarkECloudComputeServiceLiveTest.java +++ b/providers/trmk-ecloud/src/test/java/org/jclouds/vcloud/terremark/compute/TerremarkECloudComputeServiceLiveTest.java @@ -20,6 +20,8 @@ package org.jclouds.vcloud.terremark.compute; import static org.testng.Assert.assertEquals; +import java.util.Properties; + import org.jclouds.compute.BaseComputeServiceLiveTest; import org.jclouds.compute.ComputeServiceContextFactory; import org.jclouds.compute.domain.ComputeMetadata; @@ -32,16 +34,27 @@ import org.jclouds.compute.domain.TemplateBuilder; import org.jclouds.rest.RestContext; import org.jclouds.ssh.jsch.config.JschSshClientModule; import org.jclouds.vcloud.domain.VCloudExpressVApp; +import org.jclouds.vcloud.reference.VCloudConstants; import org.jclouds.vcloud.terremark.TerremarkVCloudClient; import org.testng.annotations.Test; /** - * This test is disabled, as it doesn't work while there are too few public ip addresses. + * This test is disabled, as it doesn't work while there are too few public ip + * addresses. * * @author Adrian Cole */ -@Test(groups = "live", enabled = true, sequential = true) +@Test(groups = "live", enabled = true, singleThreaded = true) public class TerremarkECloudComputeServiceLiveTest extends BaseComputeServiceLiveTest { + + @Override + protected Properties setupProperties() { + Properties props = super.setupProperties(); + props.setProperty(VCloudConstants.PROPERTY_VCLOUD_DEFAULT_VDC, + ".* - " + System.getProperty("test.trmk-ecloud.datacenter", "MIA")); + return props; + } + public TerremarkECloudComputeServiceLiveTest() { provider = "trmk-ecloud"; } @@ -60,13 +73,6 @@ public class TerremarkECloudComputeServiceLiveTest extends BaseComputeServiceLiv return template; } - // currently, the wrong CIM OSType data is coming back. - @Override - protected void checkOsMatchesTemplate(NodeMetadata node) { - if (node.getOperatingSystem() != null) - assertEquals(node.getOperatingSystem().getFamily(), null); - } - @Override public void testListImages() throws Exception { for (Image image : client.listImages()) { @@ -74,7 +80,7 @@ public class TerremarkECloudComputeServiceLiveTest extends BaseComputeServiceLiv // image.getLocationId() can be null, if it is a location-free image assertEquals(image.getType(), ComputeType.IMAGE); if (image.getOperatingSystem().getFamily() != OsFamily.WINDOWS - && image.getOperatingSystem().getFamily() != OsFamily.SOLARIS) { + && image.getOperatingSystem().getFamily() != OsFamily.SOLARIS) { assert image.getDefaultCredentials() != null && image.getDefaultCredentials().identity != null : image; assert image.getDefaultCredentials().credential != null : image; } @@ -90,7 +96,7 @@ public class TerremarkECloudComputeServiceLiveTest extends BaseComputeServiceLiv NodeMetadata allData = client.getNodeMetadata(node.getId()); System.out.println(allData.getHardware()); RestContext tmContext = new ComputeServiceContextFactory() - .createContext(provider, identity, credential).getProviderSpecificContext(); + .createContext(provider, identity, credential).getProviderSpecificContext(); VCloudExpressVApp vApp = tmContext.getApi().findVAppInOrgVDCNamed(null, null, allData.getName()); assertEquals(vApp.getName(), allData.getName()); } diff --git a/providers/trmk-ecloud/src/test/java/org/jclouds/vcloud/terremark/compute/TerremarkECloudTemplateBuilderLiveTest.java b/providers/trmk-ecloud/src/test/java/org/jclouds/vcloud/terremark/compute/TerremarkECloudTemplateBuilderLiveTest.java index 44825979e8..06d95b0de9 100644 --- a/providers/trmk-ecloud/src/test/java/org/jclouds/vcloud/terremark/compute/TerremarkECloudTemplateBuilderLiveTest.java +++ b/providers/trmk-ecloud/src/test/java/org/jclouds/vcloud/terremark/compute/TerremarkECloudTemplateBuilderLiveTest.java @@ -22,12 +22,14 @@ import static org.jclouds.compute.util.ComputeServiceUtils.getCores; import static org.testng.Assert.assertEquals; import java.io.IOException; +import java.util.Properties; import java.util.Set; import org.jclouds.compute.BaseTemplateBuilderLiveTest; import org.jclouds.compute.domain.OsFamily; import org.jclouds.compute.domain.OsFamilyVersion64Bit; import org.jclouds.compute.domain.Template; +import org.jclouds.vcloud.reference.VCloudConstants; import org.testng.annotations.Test; import com.google.common.base.Predicate; @@ -39,6 +41,13 @@ import com.google.common.collect.ImmutableSet; */ @Test(groups = "live") public class TerremarkECloudTemplateBuilderLiveTest extends BaseTemplateBuilderLiveTest { + @Override + protected Properties setupProperties() { + Properties props = super.setupProperties(); + props.setProperty(VCloudConstants.PROPERTY_VCLOUD_DEFAULT_VDC, + ".* - " + System.getProperty("test.trmk-ecloud.datacenter", "MIA")); + return props; + } public TerremarkECloudTemplateBuilderLiveTest() { provider = "trmk-ecloud"; @@ -51,20 +60,20 @@ public class TerremarkECloudTemplateBuilderLiveTest extends BaseTemplateBuilderL @Override public boolean apply(OsFamilyVersion64Bit input) { switch (input.family) { - case RHEL: - return !input.version.equals("") && !input.version.matches("5.[50]"); - case SOLARIS: - return !input.is64Bit; - case CENTOS: - return !input.version.equals("") && !input.version.matches("5.[50]"); - case UBUNTU: - return !input.version.equals("") && !input.version.equals("10.04") && !input.version.equals("8.04"); - case WINDOWS: - return !input.version.equals("") && !input.version.equals("2003 R2") // - && !(input.version.equals("2008") && !input.is64Bit) // - && !(input.version.matches("2008( R2)?") && input.is64Bit); - default: - return true; + case RHEL: + return !input.version.equals("") && !input.version.matches("5.[50]"); + case SOLARIS: + return !input.is64Bit; + case CENTOS: + return !input.version.equals("") && !input.version.matches("5.[50]"); + case UBUNTU: + return !input.version.equals("") && !input.version.equals("10.04") && !input.version.equals("8.04"); + case WINDOWS: + return !input.version.equals("") && !input.version.equals("2003 R2") // + && !(input.version.equals("2008") && !input.is64Bit) // + && !(input.version.matches("2008( R2)?") && input.is64Bit); + default: + return true; } } }; diff --git a/providers/trmk-vcloudexpress/src/test/java/org/jclouds/vcloud/terremark/TerremarkVCloudExpressAsyncClientTest.java b/providers/trmk-vcloudexpress/src/test/java/org/jclouds/vcloud/terremark/TerremarkVCloudExpressAsyncClientTest.java index 395bdcdb69..279af1dcc8 100644 --- a/providers/trmk-vcloudexpress/src/test/java/org/jclouds/vcloud/terremark/TerremarkVCloudExpressAsyncClientTest.java +++ b/providers/trmk-vcloudexpress/src/test/java/org/jclouds/vcloud/terremark/TerremarkVCloudExpressAsyncClientTest.java @@ -18,8 +18,7 @@ */ package org.jclouds.vcloud.terremark; -import static org.jclouds.Constants.PROPERTY_API_VERSION; -import static org.jclouds.Constants.PROPERTY_IDENTITY; +import static org.jclouds.Constants.PROPERTY_SESSION_INTERVAL; import static org.jclouds.vcloud.terremark.options.AddInternetServiceOptions.Builder.disabled; import static org.testng.Assert.assertEquals; @@ -28,6 +27,7 @@ import java.lang.reflect.Method; import java.net.URI; import java.util.Map; import java.util.Properties; +import java.util.concurrent.atomic.AtomicReference; import javax.inject.Inject; import javax.inject.Named; @@ -37,6 +37,7 @@ import org.jclouds.http.HttpRequest; import org.jclouds.http.RequiresHttp; import org.jclouds.http.functions.ParseSax; import org.jclouds.http.functions.ReleasePayloadAndReturn; +import org.jclouds.rest.AuthorizationException; import org.jclouds.rest.ConfiguresRestClient; import org.jclouds.rest.ResourceNotFoundException; import org.jclouds.rest.RestClientTest; @@ -47,18 +48,18 @@ import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404; import org.jclouds.rest.functions.ReturnVoidOnNotFoundOr404; import org.jclouds.rest.internal.RestAnnotationProcessor; import org.jclouds.util.Strings2; -import org.jclouds.vcloud.CommonVCloudClient; -import org.jclouds.vcloud.VCloudExpressAsyncClientTest.VCloudRestClientModuleExtension.TestOrgCatalogItemSupplier; -import org.jclouds.vcloud.VCloudExpressAsyncClientTest.VCloudRestClientModuleExtension.TestOrgCatalogSupplier; +import org.jclouds.vcloud.VCloudExpressLoginAsyncClient; +import org.jclouds.vcloud.VCloudMediaType; import org.jclouds.vcloud.VCloudVersionsAsyncClient; import org.jclouds.vcloud.domain.AllocationModel; -import org.jclouds.vcloud.domain.Capacity; -import org.jclouds.vcloud.domain.Catalog; import org.jclouds.vcloud.domain.Org; import org.jclouds.vcloud.domain.ReferenceType; import org.jclouds.vcloud.domain.Task; import org.jclouds.vcloud.domain.VCloudSession; +import org.jclouds.vcloud.domain.VDC; import org.jclouds.vcloud.domain.VDCStatus; +import org.jclouds.vcloud.domain.internal.CatalogImpl; +import org.jclouds.vcloud.domain.internal.CatalogItemImpl; import org.jclouds.vcloud.domain.internal.ReferenceTypeImpl; import org.jclouds.vcloud.domain.network.NetworkConfig; import org.jclouds.vcloud.filters.SetVCloudTokenCookie; @@ -85,12 +86,12 @@ import org.jclouds.vcloud.xml.VCloudExpressCatalogHandler; import org.jclouds.vcloud.xml.VCloudExpressVAppHandler; import org.testng.annotations.Test; -import com.google.common.base.Function; import com.google.common.base.Supplier; +import com.google.common.base.Suppliers; +import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Maps; -import com.google.inject.Injector; +import com.google.inject.AbstractModule; import com.google.inject.Module; import com.google.inject.TypeLiteral; @@ -99,10 +100,16 @@ import com.google.inject.TypeLiteral; * * @author Adrian Cole */ -// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire +// NOTE:without testName, this will not call @Before* and fail w/NPE during +// surefire @Test(groups = "unit", singleThreaded = true, testName = "TerremarkVCloudExpressAsyncClientTest") public class TerremarkVCloudExpressAsyncClientTest extends RestClientTest { + public void testListOrgs() { + assertEquals(injector.getInstance(TerremarkVCloudExpressAsyncClient.class).listOrgs().toString(), + ImmutableMap.of(ORG_REF.getName(), ORG_REF).toString()); + } + public void testCatalogItemURI() throws SecurityException, NoSuchMethodException, IOException { Method method = TerremarkVCloudExpressAsyncClient.class.getMethod("getCatalogItem", URI.class); HttpRequest request = processor.createRequest(method, @@ -631,160 +638,181 @@ public class TerremarkVCloudExpressAsyncClientTest extends RestClientTest of(CATALOG_REF.getName(), CATALOG_REF), + ImmutableMap. of(VDC_REF.getName(), VDC_REF), ImmutableMap. of( + NETWORK_REF.getName(), NETWORK_REF), ImmutableMap. of(TASKSLIST_REF.getName(), + TASKSLIST_REF), KEYSLIST_REF); + + protected static final VDC VDC = new TerremarkVDCImpl(VDC_REF.getName(), VDC_REF.getType(), VDC_REF.getHref(), + VDCStatus.READY, null, "description", ImmutableSet. of(), AllocationModel.ALLOCATION_POOL, null, null, + null, ImmutableMap. of( + "vapp", + new ReferenceTypeImpl("vapp", "application/vnd.vmware.vcloud.vApp+xml", URI + .create("https://vcloud.safesecureweb.com/api/v0.8/vApp/188849-1")), + "network", + new ReferenceTypeImpl("network", "application/vnd.vmware.vcloud.vAppTemplate+xml", URI + .create("https://vcloud.safesecureweb.com/api/v0.8/vdcItem/2"))), + ImmutableMap. of(NETWORK_REF.getName(), NETWORK_REF), 0, 0, 0, false, CATALOG_REF, + PUBLICIPS_REF, INTERNETSERVICES_REF); + @RequiresHttp @ConfiguresRestClient protected static class TerremarkVCloudRestClientModuleExtension extends TerremarkVCloudExpressRestClientModule { + @Override - protected URI provideAuthenticationURI(VCloudVersionsAsyncClient versionService, - @Named(PROPERTY_API_VERSION) String version) { - return URI.create("https://vcloud/login"); + protected URI provideAuthenticationURI(VCloudVersionsAsyncClient versionService, String version) { + return URI.create("https://vcloud.safesecureweb.com/api/v0.8/login"); + } + + @Override + protected Org provideOrg(Supplier> orgSupplier, + @org.jclouds.vcloud.endpoints.Org ReferenceType defaultOrg) { + return ORG; + } + + @Override + protected void installDefaultVCloudEndpointsModule() { + install(new AbstractModule() { + + @Override + protected void configure() { + bind(ReferenceType.class).annotatedWith(org.jclouds.vcloud.endpoints.Org.class).toInstance(ORG_REF); + bind(ReferenceType.class).annotatedWith(org.jclouds.vcloud.endpoints.Catalog.class).toInstance( + CATALOG_REF); + bind(ReferenceType.class).annotatedWith(org.jclouds.vcloud.endpoints.TasksList.class).toInstance( + TASKSLIST_REF); + bind(ReferenceType.class).annotatedWith(org.jclouds.vcloud.endpoints.VDC.class).toInstance(VDC_REF); + bind(ReferenceType.class).annotatedWith(org.jclouds.vcloud.endpoints.Network.class).toInstance( + NETWORK_REF); + } + + }); + } + + @Override + protected Supplier provideVCloudTokenCache(@Named(PROPERTY_SESSION_INTERVAL) long seconds, + AtomicReference authException, VCloudExpressLoginAsyncClient login) { + return Suppliers. ofInstance(new VCloudSession() { + + @Override + public Map getOrgs() { + return ImmutableMap. of(ORG_REF.getName(), ORG_REF); + } + + @Override + public String getVCloudToken() { + return "token"; + } + + }); + } @Override protected void configure() { super.configure(); - bind(OrgNameToKeysListSupplier.class).to(TestOrgNameToKeysListSupplier.class); - bind(OrgMapSupplier.class).to(TestTerremarkOrgMapSupplier.class); + bind(OrgMapSupplier.class).to(TestOrgMapSupplier.class); bind(OrgCatalogSupplier.class).to(TestOrgCatalogSupplier.class); bind(OrgCatalogItemSupplier.class).to(TestOrgCatalogItemSupplier.class); - bind(OrgVDCSupplier.class).to(TestTerremarkOrgVDCSupplier.class); } @Override - protected URI provideOrg(@org.jclouds.vcloud.endpoints.Org Iterable orgs) { - return URI.create("https://vcloud.safesecureweb.com/api/v0.8/org/1"); - } - - @Override - protected String provideOrgName(@org.jclouds.vcloud.endpoints.Org Iterable orgs) { - return "org"; - } - - @Override - protected URI provideCatalog(Org org, @Named(PROPERTY_IDENTITY) String user, WriteableCatalog write) { - return URI.create("https://catalog"); - } - - @Override - protected Org provideOrg(CommonVCloudClient discovery) { - return null; - } - - @Override - protected Iterable provideOrgs(Supplier cache, @Named(PROPERTY_IDENTITY) String user) { - return null; + protected Supplier>> provideOrgVDCSupplierCache( + @Named(PROPERTY_SESSION_INTERVAL) long seconds, AtomicReference authException, + OrgVDCSupplier supplier) { + return Suppliers.>> ofInstance(ImmutableMap + .> of(ORG_REF.getName(), + ImmutableMap. of(VDC.getName(), VDC))); } @Singleton - public static class TestOrgNameToKeysListSupplier extends OrgNameToKeysListSupplier { + public static class TestOrgMapSupplier extends OrgMapSupplier { + @Inject - protected TestOrgNameToKeysListSupplier(Supplier sessionSupplier) { - super(sessionSupplier, null); - } - - @Override - public Map get() { - return Maps.transformValues(sessionSupplier.get().getOrgs(), new Function() { - - @Override - public ReferenceType apply(ReferenceType from) { - return new ReferenceTypeImpl(from.getName(), TerremarkVCloudExpressMediaType.KEYSLIST_XML, URI - .create(from.getHref().toASCIIString() + "/keysList")); - } - - }); - - } - - } - - @Singleton - public static class TestTerremarkOrgMapSupplier extends OrgMapSupplier { - @Inject - protected TestTerremarkOrgMapSupplier() { + protected TestOrgMapSupplier() { super(null, null); } @Override public Map get() { - return ImmutableMap. of( - "org", - new TerremarkOrgImpl("org", null, URI.create("https://vcloud.safesecureweb.com/api/v0.8/org/1"), - null, ImmutableMap. of( - "catalog", - new ReferenceTypeImpl("catalog", TerremarkVCloudExpressMediaType.CATALOG_XML, URI - .create("https://vcloud.safesecureweb.com/api/v0.8/catalog/1"))), ImmutableMap - . of( - "vdc", - new ReferenceTypeImpl("vdc", TerremarkVCloudExpressMediaType.VDC_XML, URI - .create("https://vcloud.safesecureweb.com/api/v0.8/vdc/1"))), ImmutableMap - . of(), ImmutableMap. of( - "tasksList", - new ReferenceTypeImpl("tasksList", TerremarkVCloudExpressMediaType.TASKSLIST_XML, URI - .create("https://vcloud.safesecureweb.com/api/v0.8/tasksList/1"))), - new ReferenceTypeImpl("keysList", TerremarkVCloudExpressMediaType.KEYSLIST_XML, URI - .create("https://vcloud.safesecureweb.com/api/v0.8/keysList/1")))); + return ImmutableMap. of(ORG.getName(), ORG); } } @Singleton - public static class TestTerremarkOrgVDCSupplier extends OrgVDCSupplier { + public static class TestOrgCatalogSupplier extends OrgCatalogSupplier { @Inject - protected TestTerremarkOrgVDCSupplier() { + protected TestOrgCatalogSupplier() { super(null, null); } @Override - public Map> get() { - return ImmutableMap.> of("org", - - ImmutableMap. of( - "vdc", - new TerremarkVDCImpl("vdc", null, URI.create("https://vcloud.safesecureweb.com/api/v0.8/vdc/1"), - VDCStatus.READY, null, "description", ImmutableSet. of(), AllocationModel.UNRECOGNIZED, - new Capacity("MB", 0, 0, 0, 0), new Capacity("MB", 0, 0, 0, 0), new Capacity("MB", 0, 0, 0, 0), - ImmutableMap. of( - "vapp", - new ReferenceTypeImpl("vapp", "application/vnd.vmware.vcloud.vApp+xml", URI - .create("https://vcloud.safesecureweb.com/api/v0.8/vApp/188849-1")), - "network", - new ReferenceTypeImpl("network", "application/vnd.vmware.vcloud.vAppTemplate+xml", URI - .create("https://vcloud.safesecureweb.com/api/v0.8/vdcItem/2"))), ImmutableMap - . of(), 0, 0, 0, false, new ReferenceTypeImpl("catalog", - TerremarkVCloudExpressMediaType.CATALOG_XML, URI - .create("https://vcloud.safesecureweb.com/api/v0.8/catalog/1")), - new ReferenceTypeImpl("publicIps", TerremarkVCloudExpressMediaType.PUBLICIPSLIST_XML, URI - .create("https://vcloud.safesecureweb.com/api/v0.8/publicIps/1")), new ReferenceTypeImpl( - "internetServices", TerremarkVCloudExpressMediaType.INTERNETSERVICESLIST_XML, URI - .create("https://vcloud.safesecureweb.com/api/v0.8/internetServices/1"))))); + public Map> get() { + return ImmutableMap.> of( + ORG_REF.getName(), ImmutableMap. of( + CATALOG_REF.getName(), + new CatalogImpl(CATALOG_REF.getName(), CATALOG_REF.getType(), CATALOG_REF.getHref(), null, + "description", ImmutableMap. of( + "item", + new ReferenceTypeImpl("item", "application/vnd.vmware.vcloud.catalogItem+xml", URI + .create("https://vcloud.safesecureweb.com/api/v0.8/catalogItem/1")), + "template", + new ReferenceTypeImpl("template", "application/vnd.vmware.vcloud.vAppTemplate+xml", + URI.create("https://vcloud.safesecureweb.com/api/v0.8/catalogItem/2"))), + ImmutableList. of(), true, false))); } } - @Override - protected URI provideDefaultTasksList(Org org) { - return URI.create("https://taskslist"); + @Singleton + public static class TestOrgCatalogItemSupplier extends OrgCatalogItemSupplier { + protected TestOrgCatalogItemSupplier() { + super(null, null); + } + + @Override + public Map>> get() { + return ImmutableMap.>> of( + ORG_REF.getName(), ImmutableMap + .> of(CATALOG_REF + .getName(), ImmutableMap. of( + "template", + new CatalogItemImpl("template", URI + .create("https://vcloud.safesecureweb.com/api/v0.8/catalogItem/2"), "description", + new ReferenceTypeImpl("template", "application/vnd.vmware.vcloud.vAppTemplate+xml", + URI.create("https://vcloud.safesecureweb.com/api/v0.8/vAppTemplate/2")), + ImmutableMap. of())))); + + } } - @Override - protected URI provideDefaultVDC(Org org, @org.jclouds.vcloud.endpoints.VDC String defaultVDC) { - return URI.create("https://vdc/1"); - } - - @Override - protected String provideDefaultVDCName( - @org.jclouds.vcloud.endpoints.VDC Supplier> vDCtoOrgSupplier) { - return "vdc"; - } - - @Override - protected String provideCatalogName(Supplier>> catalogs) { - return "catalog"; - } - - @Override - protected URI provideDefaultNetwork(URI vdc, Injector injector) { - return URI.create("https://vcloud.safesecureweb.com/network/1990"); - } } } diff --git a/providers/trmk-vcloudexpress/src/test/java/org/jclouds/vcloud/terremark/TerremarkVCloudExpressClientLiveTest.java b/providers/trmk-vcloudexpress/src/test/java/org/jclouds/vcloud/terremark/TerremarkVCloudExpressClientLiveTest.java index 20c3f3544a..b9a5e082a0 100644 --- a/providers/trmk-vcloudexpress/src/test/java/org/jclouds/vcloud/terremark/TerremarkVCloudExpressClientLiveTest.java +++ b/providers/trmk-vcloudexpress/src/test/java/org/jclouds/vcloud/terremark/TerremarkVCloudExpressClientLiveTest.java @@ -22,7 +22,6 @@ import static org.jclouds.vcloud.terremark.options.TerremarkInstantiateVAppTempl import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertNotNull; -import java.util.Set; import java.util.Map.Entry; import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeoutException; @@ -51,16 +50,6 @@ public class TerremarkVCloudExpressClientLiveTest extends TerremarkClientLiveTes KeyPair key; - @Test - public void testKeysList() throws Exception { - TerremarkVCloudExpressClient vCloudExpressClient = TerremarkVCloudExpressClient.class.cast(tmClient); - TerremarkOrg org = vCloudExpressClient.findOrgNamed(null); - Set response = vCloudExpressClient.listKeyPairsInOrg(null); - assertNotNull(response); - System.err.println(response); - assertEquals(response, vCloudExpressClient.listKeyPairsInOrg(org.getHref())); - } - @Override protected void prepare() { TerremarkVCloudExpressClient vCloudExpressClient = TerremarkVCloudExpressClient.class.cast(tmClient); @@ -74,13 +63,12 @@ public class TerremarkVCloudExpressClientLiveTest extends TerremarkClientLiveTes key = vCloudExpressClient.generateKeyPairInOrg(org.getHref(), "livetest", false); } assertNotNull(key); - System.err.println(key); assertEquals(key.getName(), "livetest"); assertNotNull(key.getPrivateKey()); assertNotNull(key.getFingerPrint()); assertEquals(key.isDefault(), false); assertEquals(key.getFingerPrint(), vCloudExpressClient.findKeyPairInOrg(org.getHref(), key.getName()) - .getFingerPrint()); + .getFingerPrint()); } @AfterTest @@ -103,7 +91,7 @@ public class TerremarkVCloudExpressClientLiveTest extends TerremarkClientLiveTes @Override protected Entry getNewInternetServiceAndIpForSSH(VCloudExpressVApp vApp) { - return new TerremarkVCloudExpressInternetServiceAndPublicIpAddressSupplier(TerremarkVCloudExpressClient.class - .cast(tmClient)).getNewInternetServiceAndIp(vApp, 22, Protocol.TCP); + return new TerremarkVCloudExpressInternetServiceAndPublicIpAddressSupplier( + TerremarkVCloudExpressClient.class.cast(tmClient)).getNewInternetServiceAndIp(vApp, 22, Protocol.TCP); } } diff --git a/providers/trmk-vcloudexpress/src/test/java/org/jclouds/vcloud/terremark/compute/TerremarkVCloudExpressComputeServiceLiveTest.java b/providers/trmk-vcloudexpress/src/test/java/org/jclouds/vcloud/terremark/compute/TerremarkVCloudExpressComputeServiceLiveTest.java index 4c7158d92c..7978ef0561 100644 --- a/providers/trmk-vcloudexpress/src/test/java/org/jclouds/vcloud/terremark/compute/TerremarkVCloudExpressComputeServiceLiveTest.java +++ b/providers/trmk-vcloudexpress/src/test/java/org/jclouds/vcloud/terremark/compute/TerremarkVCloudExpressComputeServiceLiveTest.java @@ -60,13 +60,6 @@ public class TerremarkVCloudExpressComputeServiceLiveTest extends BaseComputeSer return template; } - // currently, the wrong CIM OSType data is coming back. - @Override - protected void checkOsMatchesTemplate(NodeMetadata node) { - if (node.getOperatingSystem() != null) - assertEquals(node.getOperatingSystem().getFamily(), null); - } - @Override public void testListImages() throws Exception { for (Image image : client.listImages()) { From acd4b4a628cef9e7f9da5f9836d8ec400b074c27 Mon Sep 17 00:00:00 2001 From: Adrian Cole Date: Fri, 22 Jul 2011 12:48:59 +1000 Subject: [PATCH 140/264] clean up style warnings --- .../domain/ContainerCDNMetadata.java | 2 -- .../jclouds/cloudservers/domain/Server.java | 3 -- .../CloudServersImageToImageTest.java | 6 ++-- .../functions/ServerToNodeMetadataTest.java | 6 ++-- .../java/org/jclouds/ec2/domain/Image.java | 3 -- .../functions/RegionAndIdToImageTest.java | 6 ++-- ...EC2CreateNodesInGroupThenAddToSetTest.java | 2 +- .../functions/WellKnownImageToImage.java | 4 +-- .../nova/live/novaclient/ClientBase.java | 33 +++++++++---------- .../org/jclouds/s3/domain/BucketMetadata.java | 2 -- .../swift/domain/ContainerMetadata.java | 2 -- .../domain/internal/NodeMetadataImpl.java | 25 ++++++++++---- .../compute/domain/internal/VolumeImpl.java | 2 -- .../functions/TemplateOptionsToStatement.java | 7 ++-- .../functions/SliceToNodeMetadataTest.java | 6 ++-- .../functions/SlicehostImageToImageTest.java | 6 ++-- .../VirtualMachineClientLiveTest.java | 2 ++ .../CredentialsFromAdminAccessTest.java | 2 -- .../functions/InitAdminAccessTest.java | 2 -- .../functions/ServerManagerImageToImage.java | 4 +-- 20 files changed, 59 insertions(+), 66 deletions(-) diff --git a/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/domain/ContainerCDNMetadata.java b/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/domain/ContainerCDNMetadata.java index 21c568f56e..75fef4de16 100644 --- a/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/domain/ContainerCDNMetadata.java +++ b/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/domain/ContainerCDNMetadata.java @@ -27,8 +27,6 @@ import java.net.URI; */ public class ContainerCDNMetadata implements Comparable { - /** The serialVersionUID */ - private static final long serialVersionUID = 8373435988423605652L; private String name; private boolean cdn_enabled; private long ttl; diff --git a/apis/cloudservers/src/main/java/org/jclouds/cloudservers/domain/Server.java b/apis/cloudservers/src/main/java/org/jclouds/cloudservers/domain/Server.java index c089b30251..71e047df77 100644 --- a/apis/cloudservers/src/main/java/org/jclouds/cloudservers/domain/Server.java +++ b/apis/cloudservers/src/main/java/org/jclouds/cloudservers/domain/Server.java @@ -31,16 +31,13 @@ import com.google.common.collect.Maps; public class Server { private int id; private String name; - private Map metadata = Maps.newHashMap(); - private Addresses addresses; private String adminPass; private Integer flavorId; private String hostId; private Integer imageId; private Integer sharedIpGroupId; - private Integer progress; private ServerStatus status; diff --git a/apis/cloudservers/src/test/java/org/jclouds/cloudservers/compute/functions/CloudServersImageToImageTest.java b/apis/cloudservers/src/test/java/org/jclouds/cloudservers/compute/functions/CloudServersImageToImageTest.java index dd4205b506..a30d0ddf6e 100644 --- a/apis/cloudservers/src/test/java/org/jclouds/cloudservers/compute/functions/CloudServersImageToImageTest.java +++ b/apis/cloudservers/src/test/java/org/jclouds/cloudservers/compute/functions/CloudServersImageToImageTest.java @@ -22,16 +22,16 @@ import static org.testng.Assert.assertEquals; import java.net.UnknownHostException; +import org.jclouds.cloudservers.functions.ParseImageFromJsonResponseTest; import org.jclouds.compute.config.BaseComputeServiceContextModule; import org.jclouds.compute.domain.Image; import org.jclouds.compute.domain.ImageBuilder; -import org.jclouds.compute.domain.OperatingSystemBuilder; +import org.jclouds.compute.domain.OperatingSystem; import org.jclouds.compute.domain.OsFamily; import org.jclouds.compute.reference.ComputeServiceConstants; import org.jclouds.domain.Credentials; import org.jclouds.json.Json; import org.jclouds.json.config.GsonModule; -import org.jclouds.cloudservers.functions.ParseImageFromJsonResponseTest; import org.testng.annotations.Test; import com.google.inject.Guice; @@ -49,7 +49,7 @@ public class CloudServersImageToImageTest { new ImageBuilder() .name("CentOS 5.2") .operatingSystem( - new OperatingSystemBuilder().family(OsFamily.CENTOS).version("5.2").description("CentOS 5.2").is64Bit(true) + new OperatingSystem.Builder().family(OsFamily.CENTOS).version("5.2").description("CentOS 5.2").is64Bit(true) .build()).description("CentOS 5.2").defaultCredentials(new Credentials("root", null)) .ids("2").version("1286712000000").build()); } diff --git a/apis/cloudservers/src/test/java/org/jclouds/cloudservers/compute/functions/ServerToNodeMetadataTest.java b/apis/cloudservers/src/test/java/org/jclouds/cloudservers/compute/functions/ServerToNodeMetadataTest.java index 66c710a2b7..b0ff294d83 100644 --- a/apis/cloudservers/src/test/java/org/jclouds/cloudservers/compute/functions/ServerToNodeMetadataTest.java +++ b/apis/cloudservers/src/test/java/org/jclouds/cloudservers/compute/functions/ServerToNodeMetadataTest.java @@ -34,7 +34,7 @@ import org.jclouds.compute.domain.Image; import org.jclouds.compute.domain.NodeMetadata; import org.jclouds.compute.domain.NodeMetadataBuilder; import org.jclouds.compute.domain.NodeState; -import org.jclouds.compute.domain.OperatingSystemBuilder; +import org.jclouds.compute.domain.OperatingSystem; import org.jclouds.compute.domain.OsFamily; import org.jclouds.compute.domain.Processor; import org.jclouds.compute.domain.Volume; @@ -119,7 +119,7 @@ public class ServerToNodeMetadataTest { assertEquals(metadata, new NodeMetadataBuilder().state(NodeState.PENDING).publicAddresses( ImmutableSet.of("67.23.10.132", "67.23.10.131")).privateAddresses(ImmutableSet.of("10.176.42.16")) .imageId("2").operatingSystem( - new OperatingSystemBuilder().family(OsFamily.CENTOS).description("CentOS 5.2").version("5.2") + new OperatingSystem.Builder().family(OsFamily.CENTOS).description("CentOS 5.2").version("5.2") .is64Bit(true).build()).id("1234").providerId("1234").name("sample-server").location( new LocationBuilder().scope(LocationScope.HOST).id("e4d909c290d0fb1ca068ffaddf22cbd0") .description("e4d909c290d0fb1ca068ffaddf22cbd0").parent(provider).build()) @@ -147,7 +147,7 @@ public class ServerToNodeMetadataTest { ImmutableList.of(new Processor(1.0, 1.0))).ram(256).volumes( ImmutableList.of(new VolumeBuilder().type(Volume.Type.LOCAL).size(10.0f).durable(true) .bootDevice(true).build())).build()).operatingSystem( - new OperatingSystemBuilder().family(OsFamily.CENTOS).description("CentOS 5.2").version("5.2") + new OperatingSystem.Builder().family(OsFamily.CENTOS).description("CentOS 5.2").version("5.2") .is64Bit(true).build()).id("1234").providerId("1234").name("sample-server").location( new LocationBuilder().scope(LocationScope.HOST).id("e4d909c290d0fb1ca068ffaddf22cbd0") .description("e4d909c290d0fb1ca068ffaddf22cbd0").parent(provider).build()) diff --git a/apis/ec2/src/main/java/org/jclouds/ec2/domain/Image.java b/apis/ec2/src/main/java/org/jclouds/ec2/domain/Image.java index d5e83a7542..945baf3f43 100644 --- a/apis/ec2/src/main/java/org/jclouds/ec2/domain/Image.java +++ b/apis/ec2/src/main/java/org/jclouds/ec2/domain/Image.java @@ -98,9 +98,6 @@ public class Image implements Comparable { this.hypervisor = checkNotNull(hypervisor, "hypervisor"); } - /** The serialVersionUID */ - private static final long serialVersionUID = -6965068835316857535L; - public static enum ImageState { /** * the image is successfully registered and available for launching diff --git a/apis/ec2/src/test/java/org/jclouds/ec2/compute/functions/RegionAndIdToImageTest.java b/apis/ec2/src/test/java/org/jclouds/ec2/compute/functions/RegionAndIdToImageTest.java index 16e8d5a433..99af459b0a 100644 --- a/apis/ec2/src/test/java/org/jclouds/ec2/compute/functions/RegionAndIdToImageTest.java +++ b/apis/ec2/src/test/java/org/jclouds/ec2/compute/functions/RegionAndIdToImageTest.java @@ -56,7 +56,7 @@ public class RegionAndIdToImageTest { Set images = ImmutableSet. of(ec2Image); expect(caller.getAMIServices()).andReturn(client).atLeastOnce(); - expect(client.describeImagesInRegion("region", imageIds("ami"))).andReturn((Set) images); + expect(client.describeImagesInRegion("region", imageIds("ami"))).andReturn(Set.class.cast(images)); expect(parser.apply(ec2Image)).andReturn(image); replay(caller); @@ -87,7 +87,7 @@ public class RegionAndIdToImageTest { Set images = ImmutableSet. of(ec2Image); expect(caller.getAMIServices()).andReturn(client).atLeastOnce(); - expect(client.describeImagesInRegion("region", imageIds("ami"))).andReturn((Set) images); + expect(client.describeImagesInRegion("region", imageIds("ami"))).andReturn(Set.class.cast(images)); expect(parser.apply(ec2Image)).andThrow(new ResourceNotFoundException()); replay(caller); @@ -118,7 +118,7 @@ public class RegionAndIdToImageTest { Set images = ImmutableSet. of(ec2Image); expect(caller.getAMIServices()).andReturn(client).atLeastOnce(); - expect(client.describeImagesInRegion("region", imageIds("ami"))).andReturn((Set) images); + expect(client.describeImagesInRegion("region", imageIds("ami"))).andReturn(Set.class.cast(images)); expect(parser.apply(ec2Image)).andThrow(new NoSuchElementException()); replay(caller); diff --git a/apis/ec2/src/test/java/org/jclouds/ec2/compute/strategy/EC2CreateNodesInGroupThenAddToSetTest.java b/apis/ec2/src/test/java/org/jclouds/ec2/compute/strategy/EC2CreateNodesInGroupThenAddToSetTest.java index 72b890ab13..c64e94516f 100644 --- a/apis/ec2/src/test/java/org/jclouds/ec2/compute/strategy/EC2CreateNodesInGroupThenAddToSetTest.java +++ b/apis/ec2/src/test/java/org/jclouds/ec2/compute/strategy/EC2CreateNodesInGroupThenAddToSetTest.java @@ -121,7 +121,7 @@ public class EC2CreateNodesInGroupThenAddToSetTest { expect(input.template.getImage()).andReturn(input.image).atLeastOnce(); expect(input.image.getProviderId()).andReturn(imageId).atLeastOnce(); expect(instanceClient.runInstancesInRegion(region, zone, imageId, 1, input.count, ec2Options)).andReturn( - (Reservation) reservation); + Reservation.class.cast(reservation)); expect(instance.getId()).andReturn(instanceCreatedId).atLeastOnce(); // simulate a lazy credentials fetch Credentials creds = new Credentials("foo", "bar"); diff --git a/apis/elasticstack/src/main/java/org/jclouds/elasticstack/compute/functions/WellKnownImageToImage.java b/apis/elasticstack/src/main/java/org/jclouds/elasticstack/compute/functions/WellKnownImageToImage.java index a86912859d..17d4f1bfa6 100644 --- a/apis/elasticstack/src/main/java/org/jclouds/elasticstack/compute/functions/WellKnownImageToImage.java +++ b/apis/elasticstack/src/main/java/org/jclouds/elasticstack/compute/functions/WellKnownImageToImage.java @@ -25,7 +25,7 @@ import javax.inject.Singleton; import org.jclouds.compute.domain.Image; import org.jclouds.compute.domain.ImageBuilder; -import org.jclouds.compute.domain.OperatingSystemBuilder; +import org.jclouds.compute.domain.OperatingSystem; import org.jclouds.domain.Credentials; import org.jclouds.domain.Location; import org.jclouds.elasticstack.domain.DriveInfo; @@ -57,7 +57,7 @@ public class WellKnownImageToImage implements Function { .put("size", input.getSize() + "").build()).defaultCredentials( new Credentials(input.getLoginUser(), null)).location(locationSupplier.get()).name( input.getDescription()).description(drive.getName()).operatingSystem( - new OperatingSystemBuilder().family(input.getOsFamily()).version(input.getOsVersion()).name( + new OperatingSystem.Builder().family(input.getOsFamily()).version(input.getOsVersion()).name( input.getDescription()).description(drive.getName()).is64Bit(input.is64bit()).build()).version( "").build(); } diff --git a/apis/nova/src/test/java/org/jclouds/openstack/nova/live/novaclient/ClientBase.java b/apis/nova/src/test/java/org/jclouds/openstack/nova/live/novaclient/ClientBase.java index 047e8b1342..179b60e9c7 100644 --- a/apis/nova/src/test/java/org/jclouds/openstack/nova/live/novaclient/ClientBase.java +++ b/apis/nova/src/test/java/org/jclouds/openstack/nova/live/novaclient/ClientBase.java @@ -18,13 +18,16 @@ */ package org.jclouds.openstack.nova.live.novaclient; -import com.google.common.base.Predicate; -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableSet; -import com.google.inject.Injector; -import com.google.inject.Module; -import org.jclouds.domain.Credentials; -import org.jclouds.http.handlers.BackoffLimitedRetryHandler; +import static org.jclouds.openstack.nova.live.PropertyHelper.setupKeyPair; +import static org.jclouds.openstack.nova.live.PropertyHelper.setupOverrides; +import static org.jclouds.openstack.nova.live.PropertyHelper.setupProperties; +import static org.jclouds.openstack.nova.options.CreateServerOptions.Builder.withFile; + +import java.io.IOException; +import java.util.Map; +import java.util.Properties; +import java.util.concurrent.TimeUnit; + import org.jclouds.logging.slf4j.config.SLF4JLoggingModule; import org.jclouds.net.IPSocket; import org.jclouds.openstack.nova.NovaClient; @@ -34,20 +37,14 @@ import org.jclouds.predicates.RetryablePredicate; import org.jclouds.predicates.SocketOpen; import org.jclouds.rest.RestContextFactory; import org.jclouds.ssh.SshClient; -import org.jclouds.ssh.SshException; -import org.jclouds.ssh.jsch.JschSshClient; import org.jclouds.ssh.jsch.config.JschSshClientModule; import org.testng.annotations.BeforeTest; -import java.io.IOException; -import java.net.URISyntaxException; -import java.util.Map; -import java.util.Properties; -import java.util.Set; -import java.util.concurrent.TimeUnit; - -import static org.jclouds.openstack.nova.live.PropertyHelper.*; -import static org.jclouds.openstack.nova.options.CreateServerOptions.Builder.withFile; +import com.google.common.base.Predicate; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableSet; +import com.google.inject.Injector; +import com.google.inject.Module; /** * @author Victor Galkin diff --git a/apis/s3/src/main/java/org/jclouds/s3/domain/BucketMetadata.java b/apis/s3/src/main/java/org/jclouds/s3/domain/BucketMetadata.java index 96130aa2f4..75f6877ac3 100644 --- a/apis/s3/src/main/java/org/jclouds/s3/domain/BucketMetadata.java +++ b/apis/s3/src/main/java/org/jclouds/s3/domain/BucketMetadata.java @@ -26,8 +26,6 @@ import java.util.Date; * @author Adrian Cole */ public class BucketMetadata implements Comparable { - /** The serialVersionUID */ - private static final long serialVersionUID = -6965068835316857535L; private final Date creationDate; private final CanonicalUser owner; private final String name; diff --git a/apis/swift/src/main/java/org/jclouds/openstack/swift/domain/ContainerMetadata.java b/apis/swift/src/main/java/org/jclouds/openstack/swift/domain/ContainerMetadata.java index 08378c64dc..213c2012d2 100644 --- a/apis/swift/src/main/java/org/jclouds/openstack/swift/domain/ContainerMetadata.java +++ b/apis/swift/src/main/java/org/jclouds/openstack/swift/domain/ContainerMetadata.java @@ -25,8 +25,6 @@ package org.jclouds.openstack.swift.domain; * */ public class ContainerMetadata implements Comparable { - /** The serialVersionUID */ - private static final long serialVersionUID = 2925863715029426128L; private String name; private long count; private long bytes; diff --git a/compute/src/main/java/org/jclouds/compute/domain/internal/NodeMetadataImpl.java b/compute/src/main/java/org/jclouds/compute/domain/internal/NodeMetadataImpl.java index 108c650ad9..20c532bf07 100644 --- a/compute/src/main/java/org/jclouds/compute/domain/internal/NodeMetadataImpl.java +++ b/compute/src/main/java/org/jclouds/compute/domain/internal/NodeMetadataImpl.java @@ -61,12 +61,14 @@ public class NodeMetadataImpl extends ComputeMetadataImpl implements NodeMetadat private final Hardware hardware; @Nullable private final OperatingSystem os; - + @Nullable + private final String hostname; + public NodeMetadataImpl(String providerId, String name, String id, Location location, URI uri, Map userMetadata, Set tags, @Nullable String group, @Nullable Hardware hardware, @Nullable String imageId, @Nullable OperatingSystem os, NodeState state, int loginPort, Iterable publicAddresses, Iterable privateAddresses, @Nullable String adminPassword, - @Nullable Credentials credentials) { + @Nullable Credentials credentials, String hostname) { super(ComputeType.NODE, providerId, name, id, location, uri, userMetadata, tags); this.group = group; this.hardware = hardware; @@ -78,6 +80,7 @@ public class NodeMetadataImpl extends ComputeMetadataImpl implements NodeMetadat this.privateAddresses = ImmutableSet.copyOf(checkNotNull(privateAddresses, "privateAddresses")); this.adminPassword = adminPassword; this.credentials = credentials; + this.hostname = hostname; } /** @@ -168,14 +171,22 @@ public class NodeMetadataImpl extends ComputeMetadataImpl implements NodeMetadat return os; } + /** + * {@inheritDoc} + */ + @Override + public String getHostname() { + return hostname; + } + @Override public String toString() { return "[id=" + getId() + ", providerId=" + getProviderId() + ", group=" + getTag() + ", name=" + getName() - + ", location=" + getLocation() + ", uri=" + getUri() + ", imageId=" + getImageId() + ", os=" - + getOperatingSystem() + ", state=" + getState() + ", loginPort=" + getLoginPort() - + ", privateAddresses=" + privateAddresses + ", publicAddresses=" + publicAddresses + ", hardware=" - + getHardware() + ", loginUser=" + ((credentials != null) ? credentials.identity : null) - + ", userMetadata=" + getUserMetadata() + ", tags=" + tags + "]"; + + ", location=" + getLocation() + ", uri=" + getUri() + ", imageId=" + getImageId() + ", os=" + + getOperatingSystem() + ", state=" + getState() + ", loginPort=" + getLoginPort() + ", hostname=" + + getHostname() + ", privateAddresses=" + privateAddresses + ", publicAddresses=" + publicAddresses + + ", hardware=" + getHardware() + ", loginUser=" + ((credentials != null) ? credentials.identity : null) + + ", userMetadata=" + getUserMetadata() + ", tags=" + tags + "]"; } @Override diff --git a/compute/src/main/java/org/jclouds/compute/domain/internal/VolumeImpl.java b/compute/src/main/java/org/jclouds/compute/domain/internal/VolumeImpl.java index fe9098a13f..4d1483fc9b 100644 --- a/compute/src/main/java/org/jclouds/compute/domain/internal/VolumeImpl.java +++ b/compute/src/main/java/org/jclouds/compute/domain/internal/VolumeImpl.java @@ -28,8 +28,6 @@ import org.jclouds.compute.domain.Volume; * @author Adrian Cole */ public class VolumeImpl implements Volume { - /** The serialVersionUID */ - private static final long serialVersionUID = -3306004212804159093L; private final String id; private final Volume.Type type; diff --git a/compute/src/main/java/org/jclouds/compute/functions/TemplateOptionsToStatement.java b/compute/src/main/java/org/jclouds/compute/functions/TemplateOptionsToStatement.java index 3645088161..42f21d6eec 100644 --- a/compute/src/main/java/org/jclouds/compute/functions/TemplateOptionsToStatement.java +++ b/compute/src/main/java/org/jclouds/compute/functions/TemplateOptionsToStatement.java @@ -26,12 +26,13 @@ import javax.inject.Singleton; import org.jclouds.compute.options.TemplateOptions; import org.jclouds.scriptbuilder.InitBuilder; -import org.jclouds.scriptbuilder.domain.AuthorizeRSAPublicKey; -import org.jclouds.scriptbuilder.domain.InstallRSAPrivateKey; import org.jclouds.scriptbuilder.domain.Statement; import org.jclouds.scriptbuilder.domain.StatementList; +import org.jclouds.scriptbuilder.statements.ssh.AuthorizeRSAPublicKeys; +import org.jclouds.scriptbuilder.statements.ssh.InstallRSAPrivateKey; import com.google.common.base.Function; +import com.google.common.collect.ImmutableSet; /** * @@ -44,7 +45,7 @@ public class TemplateOptionsToStatement implements Function bootstrap = newArrayList(); if (options.getPublicKey() != null) - bootstrap.add(new AuthorizeRSAPublicKey(options.getPublicKey())); + bootstrap.add(new AuthorizeRSAPublicKeys(ImmutableSet.of(options.getPublicKey()))); if (options.getRunScript() != null) bootstrap.add(options.getRunScript()); if (options.getPrivateKey() != null) diff --git a/providers/slicehost/src/test/java/org/jclouds/slicehost/compute/functions/SliceToNodeMetadataTest.java b/providers/slicehost/src/test/java/org/jclouds/slicehost/compute/functions/SliceToNodeMetadataTest.java index 022638b5ad..be9f664484 100644 --- a/providers/slicehost/src/test/java/org/jclouds/slicehost/compute/functions/SliceToNodeMetadataTest.java +++ b/providers/slicehost/src/test/java/org/jclouds/slicehost/compute/functions/SliceToNodeMetadataTest.java @@ -30,7 +30,7 @@ import org.jclouds.compute.domain.Image; import org.jclouds.compute.domain.NodeMetadata; import org.jclouds.compute.domain.NodeMetadataBuilder; import org.jclouds.compute.domain.NodeState; -import org.jclouds.compute.domain.OperatingSystemBuilder; +import org.jclouds.compute.domain.OperatingSystem; import org.jclouds.compute.domain.OsFamily; import org.jclouds.compute.domain.Processor; import org.jclouds.compute.domain.Volume; @@ -111,7 +111,7 @@ public class SliceToNodeMetadataTest { assertEquals(metadata, new NodeMetadataBuilder().state(NodeState.PENDING).publicAddresses( ImmutableSet.of("174.143.212.229")).privateAddresses(ImmutableSet.of("10.176.164.199")).group("jclouds") .imageId("2").operatingSystem( - new OperatingSystemBuilder().family(OsFamily.CENTOS).description("CentOS 5.2").version("5.2") + new OperatingSystem.Builder().family(OsFamily.CENTOS).description("CentOS 5.2").version("5.2") .is64Bit(true).build()).id("1").providerId("1").name("jclouds-foo").location(provider) .userMetadata(ImmutableMap.of("Server Label", "Web Head 1", "Image Version", "2.1")).build()); } @@ -135,7 +135,7 @@ public class SliceToNodeMetadataTest { ImmutableList.of(new Processor(0.25, 1.0))).ram(256).volumes( ImmutableList.of(new VolumeBuilder().type(Volume.Type.LOCAL).size(1.0f).durable(true) .bootDevice(true).build())).build()).operatingSystem( - new OperatingSystemBuilder().family(OsFamily.CENTOS).description("CentOS 5.2").version("5.2") + new OperatingSystem.Builder().family(OsFamily.CENTOS).description("CentOS 5.2").version("5.2") .is64Bit(true).build()).id("1").providerId("1").name("jclouds-foo").location(provider) .userMetadata(ImmutableMap.of("Server Label", "Web Head 1", "Image Version", "2.1")).build()); } diff --git a/providers/slicehost/src/test/java/org/jclouds/slicehost/compute/functions/SlicehostImageToImageTest.java b/providers/slicehost/src/test/java/org/jclouds/slicehost/compute/functions/SlicehostImageToImageTest.java index 046d97de31..02b36cc6fc 100644 --- a/providers/slicehost/src/test/java/org/jclouds/slicehost/compute/functions/SlicehostImageToImageTest.java +++ b/providers/slicehost/src/test/java/org/jclouds/slicehost/compute/functions/SlicehostImageToImageTest.java @@ -25,7 +25,7 @@ import java.net.UnknownHostException; import org.jclouds.compute.config.BaseComputeServiceContextModule; import org.jclouds.compute.domain.Image; import org.jclouds.compute.domain.ImageBuilder; -import org.jclouds.compute.domain.OperatingSystemBuilder; +import org.jclouds.compute.domain.OperatingSystem; import org.jclouds.compute.domain.OsFamily; import org.jclouds.compute.reference.ComputeServiceConstants; import org.jclouds.domain.Credentials; @@ -49,7 +49,7 @@ public class SlicehostImageToImageTest { @Test public void test() throws UnknownHostException { assertEquals(convertImage(), new ImageBuilder().name("CentOS 5.2").operatingSystem( - new OperatingSystemBuilder().family(OsFamily.CENTOS).version("5.2").description("CentOS 5.2").is64Bit( + new OperatingSystem.Builder().family(OsFamily.CENTOS).version("5.2").description("CentOS 5.2").is64Bit( true).build()).description("CentOS 5.2").defaultCredentials(new Credentials("root", null)).ids( "2").build()); } @@ -58,7 +58,7 @@ public class SlicehostImageToImageTest { public void test32() throws UnknownHostException { assertEquals(convertImage("/test_get_image32.xml"), new ImageBuilder().name("Ubuntu 10.10 (maverick) 32-bit") .operatingSystem( - new OperatingSystemBuilder().family(OsFamily.UBUNTU).version("10.10").description( + new OperatingSystem.Builder().family(OsFamily.UBUNTU).version("10.10").description( "Ubuntu 10.10 (maverick) 32-bit").build()).description( "Ubuntu 10.10 (maverick) 32-bit").defaultCredentials(new Credentials("root", null)).ids("70") .build()); diff --git a/sandbox-apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/VirtualMachineClientLiveTest.java b/sandbox-apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/VirtualMachineClientLiveTest.java index 22b5a2c953..494a83679a 100644 --- a/sandbox-apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/VirtualMachineClientLiveTest.java +++ b/sandbox-apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/VirtualMachineClientLiveTest.java @@ -120,6 +120,7 @@ public class VirtualMachineClientLiveTest extends BaseCloudStackClientLiveTest { final Predicate