diff --git a/compute/src/main/resources/compute.properties b/compute/src/main/resources/compute.properties index 2cf7f8f679..4a42445731 100644 --- a/compute/src/main/resources/compute.properties +++ b/compute/src/main/resources/compute.properties @@ -28,5 +28,7 @@ ec2.contextbuilder=org.jclouds.aws.ec2.EC2ContextBuilder ec2.propertiesbuilder=org.jclouds.aws.ec2.EC2PropertiesBuilder cloudservers.contextbuilder=org.jclouds.rackspace.cloudservers.CloudServersContextBuilder cloudservers.propertiesbuilder=org.jclouds.rackspace.RackspacePropertiesBuilder +bluelock.contextbuilder=org.jclouds.vcloud.bluelock.BlueLockVCloudContextBuilder +bluelock.propertiesbuilder=org.jclouds.vcloud.bluelock.BlueLockVCloudPropertiesBuilder # example of where to change your endpoint -# ec2.endpoint=https://ec2.us-west-1.amazonaws.com \ No newline at end of file +# bluelock.endpoint=https://express3.bluelock.com/api diff --git a/vcloud/bluelock/README.txt b/vcloud/bluelock/README.txt new file mode 100644 index 0000000000..dcb9434220 --- /dev/null +++ b/vcloud/bluelock/README.txt @@ -0,0 +1,24 @@ +==== + + Copyright (C) 2009 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. + ==================================================================== +==== +# +# The jclouds provider for Hosting.com's vCloud Express (http://www.bluelock/vcloudexpress/) platform. +# +# TODO: Implementation status. +# TODO: Supported features. +# TODO: Usage example. diff --git a/vcloud/bluelock/pom.xml b/vcloud/bluelock/pom.xml new file mode 100644 index 0000000000..7b1a836a6e --- /dev/null +++ b/vcloud/bluelock/pom.xml @@ -0,0 +1,60 @@ + + + + + 4.0.0 + + org.jclouds + jclouds-vcloud-project + 1.0-SNAPSHOT + + org.jclouds + jclouds-bluelock + jclouds bluelock Components Core + jclouds core components to access bluelock + + ${jclouds.bluelock.user} + ${jclouds.bluelock.password} + + + + scm:svn:http://jclouds.googlecode.com/svn/trunk/vcloud/bluelock + scm:svn:https://jclouds.googlecode.com/svn/trunk/vcloud/bluelock + http://jclouds.googlecode.com/svn/trunk/vcloud/bluelock + + + + + ${project.groupId} + jclouds-vcloud + ${project.version} + + + ${project.groupId} + jclouds-vcloud + ${project.version} + test-jar + test + + + + diff --git a/vcloud/bluelock/src/main/java/org/jclouds/vcloud/bluelock/BlueLockVCloudContextBuilder.java b/vcloud/bluelock/src/main/java/org/jclouds/vcloud/bluelock/BlueLockVCloudContextBuilder.java new file mode 100644 index 0000000000..ab444e4134 --- /dev/null +++ b/vcloud/bluelock/src/main/java/org/jclouds/vcloud/bluelock/BlueLockVCloudContextBuilder.java @@ -0,0 +1,57 @@ +/** + * + * Copyright (C) 2009 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.bluelock; + +import java.util.List; +import java.util.Properties; + +import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule; +import org.jclouds.logging.jdk.config.JDKLoggingModule; +import org.jclouds.vcloud.VCloudContextBuilder; +import org.jclouds.vcloud.bluelock.config.BlueLockVCloudRestClientModule; + +import com.google.inject.Injector; +import com.google.inject.Module; + +/** + * Creates {@link BlueLockVCloudComputeServiceContext} or {@link Injector} instances based on + * the most commonly requested arguments. + *

+ * Note that Threadsafe objects will be bound as singletons to the Injector or Context provided. + *

+ *

+ * If no Modules are specified, the default {@link JDKLoggingModule logging} and + * {@link JavaUrlHttpCommandExecutorServiceModule http transports} will be installed. + * + * @author Adrian Cole + * @see BlueLockVCloudComputeServiceContext + */ +public class BlueLockVCloudContextBuilder extends + VCloudContextBuilder { + + public BlueLockVCloudContextBuilder(Properties props) { + super(props); + } + + @Override + protected void addClientModule(List modules) { + modules.add(new BlueLockVCloudRestClientModule()); + } + +} diff --git a/vcloud/bluelock/src/main/java/org/jclouds/vcloud/bluelock/BlueLockVCloudContextFactory.java b/vcloud/bluelock/src/main/java/org/jclouds/vcloud/bluelock/BlueLockVCloudContextFactory.java new file mode 100644 index 0000000000..f6942f7095 --- /dev/null +++ b/vcloud/bluelock/src/main/java/org/jclouds/vcloud/bluelock/BlueLockVCloudContextFactory.java @@ -0,0 +1,69 @@ +/** + * + * Copyright (C) 2009 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.bluelock; + +import java.net.URI; +import java.util.Properties; + +import org.jclouds.compute.ComputeServiceContext; +import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule; +import org.jclouds.logging.jdk.config.JDKLoggingModule; + +import com.google.inject.Module; + +/** + * Creates {@link BlueLockVCloudComputeServiceContext} instances based on the most commonly + * requested arguments. + *

+ * Note that Threadsafe objects will be bound as singletons to the Injector or Context provided. + *

+ *

+ * If no Modules are specified, the default {@link JDKLoggingModule logging} and + * {@link JavaUrlHttpCommandExecutorServiceModule http transports} will be installed. + * + * @author Adrian Cole + * @see BlueLockVCloudComputeServiceContext + */ +public class BlueLockVCloudContextFactory { + public static ComputeServiceContext createContext(Properties properties, Module... modules) { + return new BlueLockVCloudContextBuilder( + new BlueLockVCloudPropertiesBuilder(properties).build()).withModules(modules) + .buildComputeServiceContext(); + } + + public static ComputeServiceContext createContext(String user, String key, Module... modules) { + return new BlueLockVCloudContextBuilder( + new BlueLockVCloudPropertiesBuilder(user, key).build()).withModules(modules) + .buildComputeServiceContext(); + } + + public static ComputeServiceContext createContext(Properties properties, String user, + String key, Module... modules) { + return new BlueLockVCloudContextBuilder( + new BlueLockVCloudPropertiesBuilder(properties).withCredentials(user, key) + .build()).withModules(modules).buildComputeServiceContext(); + } + + public static ComputeServiceContext createContext(URI endpoint, String user, String key, + Module... modules) { + return new BlueLockVCloudContextBuilder( + new BlueLockVCloudPropertiesBuilder(user, key).withEndpoint(endpoint).build()) + .withModules(modules).buildComputeServiceContext(); + } +} diff --git a/vcloud/bluelock/src/main/java/org/jclouds/vcloud/bluelock/BlueLockVCloudPropertiesBuilder.java b/vcloud/bluelock/src/main/java/org/jclouds/vcloud/bluelock/BlueLockVCloudPropertiesBuilder.java new file mode 100644 index 0000000000..b9f391c22b --- /dev/null +++ b/vcloud/bluelock/src/main/java/org/jclouds/vcloud/bluelock/BlueLockVCloudPropertiesBuilder.java @@ -0,0 +1,48 @@ +/** + * + * Copyright (C) 2009 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.bluelock; + +import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_ENDPOINT; + +import java.net.URI; +import java.util.Properties; + +import org.jclouds.vcloud.VCloudPropertiesBuilder; + +/** + * Builds properties used in bluelock VCloud Clients + * + * @author Adrian Cole + */ +public class BlueLockVCloudPropertiesBuilder extends VCloudPropertiesBuilder { + @Override + protected Properties defaultProperties() { + Properties properties = super.defaultProperties(); + properties.setProperty(PROPERTY_VCLOUD_ENDPOINT, "https://express3.bluelock.com/api"); + return properties; + } + + public BlueLockVCloudPropertiesBuilder(Properties properties) { + super(properties); + } + + public BlueLockVCloudPropertiesBuilder(String id, String secret) { + super(URI.create("https://express3.bluelock.com/api"), id, secret); + } +} diff --git a/vcloud/bluelock/src/main/java/org/jclouds/vcloud/bluelock/compute/config/BlueLockVCloudComputeServiceContextModule.java b/vcloud/bluelock/src/main/java/org/jclouds/vcloud/bluelock/compute/config/BlueLockVCloudComputeServiceContextModule.java new file mode 100644 index 0000000000..73d42c4290 --- /dev/null +++ b/vcloud/bluelock/src/main/java/org/jclouds/vcloud/bluelock/compute/config/BlueLockVCloudComputeServiceContextModule.java @@ -0,0 +1,37 @@ +/** + * + * Copyright (C) 2009 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.bluelock.compute.config; + +import org.jclouds.vcloud.compute.config.VCloudComputeServiceContextModule; + +/** + * Configures the {@link BlueLockVCloudComputeServiceContext}; requires + * {@link BlueLockVCloudComputeClient} bound. + * + * @author Adrian Cole + */ +public class BlueLockVCloudComputeServiceContextModule extends + VCloudComputeServiceContextModule { + + @Override + protected void configure() { + super.configure(); + } + +} diff --git a/vcloud/bluelock/src/main/java/org/jclouds/vcloud/bluelock/config/BlueLockVCloudRestClientModule.java b/vcloud/bluelock/src/main/java/org/jclouds/vcloud/bluelock/config/BlueLockVCloudRestClientModule.java new file mode 100644 index 0000000000..c941702ddb --- /dev/null +++ b/vcloud/bluelock/src/main/java/org/jclouds/vcloud/bluelock/config/BlueLockVCloudRestClientModule.java @@ -0,0 +1,76 @@ +/** + * + * Copyright (C) 2009 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.bluelock.config; + +import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_USER; + +import java.net.URI; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.TimeoutException; + +import javax.inject.Named; + +import org.jclouds.http.RequiresHttp; +import org.jclouds.rest.ConfiguresRestClient; +import org.jclouds.vcloud.VCloudAsyncClient; +import org.jclouds.vcloud.config.VCloudRestClientModule; +import org.jclouds.vcloud.domain.NamedResource; +import org.jclouds.vcloud.domain.Organization; + +import com.google.common.base.Predicate; +import com.google.common.collect.Iterables; + +/** + * Configures the VCloud authentication service connection, including logging and http transport. + * + * @author Adrian Cole + */ +@RequiresHttp +@ConfiguresRestClient +public class BlueLockVCloudRestClientModule extends VCloudRestClientModule { + + @Override + protected URI provideDefaultNetwork(VCloudAsyncClient client) throws InterruptedException, + ExecutionException, TimeoutException { + return Iterables.getOnlyElement( + Iterables.filter(client.getDefaultVDC().get(180, TimeUnit.SECONDS) + .getAvailableNetworks().values(), new Predicate() { + + @Override + public boolean apply(NamedResource input) { + return input.getName().endsWith("Public"); + } + + })).getLocation(); + } + + @Override + protected URI provideCatalog(Organization org, @Named(PROPERTY_VCLOUD_USER) final String user) { + return Iterables.getOnlyElement( + Iterables.filter(org.getCatalogs().values(), new Predicate() { + + @Override + public boolean apply(NamedResource input) { + return input.getName().startsWith(user); + } + + })).getLocation(); + } +} diff --git a/vcloud/bluelock/src/test/java/org/jclouds/vcloud/bluelock/BlueLockVCloudClientLiveTest.java b/vcloud/bluelock/src/test/java/org/jclouds/vcloud/bluelock/BlueLockVCloudClientLiveTest.java new file mode 100644 index 0000000000..e033575ebe --- /dev/null +++ b/vcloud/bluelock/src/test/java/org/jclouds/vcloud/bluelock/BlueLockVCloudClientLiveTest.java @@ -0,0 +1,67 @@ +/** + * + * Copyright (C) 2009 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.bluelock; + +import static com.google.common.base.Preconditions.checkNotNull; + +import org.jclouds.http.HttpResponseException; +import org.jclouds.logging.log4j.config.Log4JLoggingModule; +import org.jclouds.ssh.jsch.config.JschSshClientModule; +import org.jclouds.vcloud.VCloudClient; +import org.jclouds.vcloud.VCloudClientLiveTest; +import org.testng.annotations.BeforeGroups; +import org.testng.annotations.Test; + +import com.google.inject.Injector; + +/** + * Tests behavior of {@code BlueLockVCloudClient} + * + * @author Adrian Cole + */ +@Test(groups = "live", sequential = true, testName = "vcloud.BlueLockVCloudClientLiveTest") +public class BlueLockVCloudClientLiveTest extends VCloudClientLiveTest { + + @BeforeGroups(groups = { "live" }) + @Override + public void setupClient() { + account = checkNotNull(System.getProperty("jclouds.test.user"), "jclouds.test.user"); + String key = checkNotNull(System.getProperty("jclouds.test.key"), "jclouds.test.key"); + Injector injector = new BlueLockVCloudContextBuilder(new BlueLockVCloudPropertiesBuilder( + account, key).build()).withModules(new Log4JLoggingModule(), + new JschSshClientModule()).buildInjector(); + + connection = injector.getInstance(VCloudClient.class); + } + + // https://forums.bluelock.com/showthread.php?t=112 + @Override + @Test(expectedExceptions = HttpResponseException.class) + public void testGetNetwork() throws Exception { + super.testGetNetwork(); + } + + // https://forums.bluelock.com/showthread.php?t=113 + @Override + @Test(expectedExceptions = HttpResponseException.class) + public void testGetTask() throws Exception { + super.testGetTask(); + } + +} diff --git a/vcloud/bluelock/src/test/java/org/jclouds/vcloud/bluelock/compute/BlueLockVCloudComputeServiceLiveTest.java b/vcloud/bluelock/src/test/java/org/jclouds/vcloud/bluelock/compute/BlueLockVCloudComputeServiceLiveTest.java new file mode 100644 index 0000000000..359bd9553b --- /dev/null +++ b/vcloud/bluelock/src/test/java/org/jclouds/vcloud/bluelock/compute/BlueLockVCloudComputeServiceLiveTest.java @@ -0,0 +1,83 @@ +/** + * + * Copyright (C) 2009 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.bluelock.compute; + +import static org.jclouds.compute.domain.OsFamily.UBUNTU; +import static org.testng.Assert.assertEquals; + +import java.util.Map; + +import org.jclouds.compute.BaseComputeServiceLiveTest; +import org.jclouds.compute.domain.Image; +import org.jclouds.compute.domain.Template; +import org.jclouds.compute.domain.TemplateBuilder; +import org.jclouds.ssh.jsch.config.JschSshClientModule; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +/** + * + * + * @author Adrian Cole + */ +@Test(groups = "live", enabled = true, sequential = true, testName = "compute.BlueLockVCloudComputeServiceLiveTest") +public class BlueLockVCloudComputeServiceLiveTest extends BaseComputeServiceLiveTest { + @BeforeClass + @Override + public void setServiceDefaults() { + service = "bluelock"; + } + + protected Template buildTemplate(TemplateBuilder templateBuilder) { + return templateBuilder.osFamily(UBUNTU).smallest().build(); + } + + @Override + protected JschSshClientModule getSshModule() { + return new JschSshClientModule(); + } + + @Override + public void testListImages() throws Exception { + super.testListImages(); + Map images = client.getImages(); + assertEquals(images.size(), 5); + // TODO verify parsing works + } + + // https://forums.bluelock.com/showthread.php?p=353#post353 + @Override + @Test(enabled = false) + public void testCreate() throws Exception { + super.testCreate(); + } + + @Override + @Test(enabled = false) + public void testGet() throws Exception { + super.testGet(); + } + + @Override + @Test(enabled = false) + public void testReboot() throws Exception { + super.testReboot(); + } +} diff --git a/vcloud/bluelock/src/test/java/org/jclouds/vcloud/bluelock/compute/PropertiesTest.java b/vcloud/bluelock/src/test/java/org/jclouds/vcloud/bluelock/compute/PropertiesTest.java new file mode 100644 index 0000000000..24ec3dada0 --- /dev/null +++ b/vcloud/bluelock/src/test/java/org/jclouds/vcloud/bluelock/compute/PropertiesTest.java @@ -0,0 +1,54 @@ +/** + * + * Copyright (C) 2009 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.bluelock.compute; + +import static org.testng.Assert.assertEquals; + +import java.io.IOException; +import java.util.Properties; + +import org.jclouds.vcloud.bluelock.BlueLockVCloudContextBuilder; +import org.jclouds.vcloud.bluelock.BlueLockVCloudPropertiesBuilder; +import org.testng.annotations.BeforeTest; +import org.testng.annotations.Test; + +import com.google.common.io.Resources; + +/** + * @author Adrian Cole + */ +@Test(groups = "unit", testName = "compute.PropertiesTest") +public class PropertiesTest { + private Properties properties; + + @BeforeTest + public void setUp() throws IOException { + properties = new Properties(); + properties.load(Resources.newInputStreamSupplier(Resources.getResource("compute.properties")) + .getInput()); + } + + public void test() { + assertEquals(properties.getProperty("bluelock.contextbuilder"), + BlueLockVCloudContextBuilder.class.getName()); + assertEquals(properties.getProperty("bluelock.propertiesbuilder"), + BlueLockVCloudPropertiesBuilder.class.getName()); + } + +} diff --git a/vcloud/bluelock/src/test/resources/log4j.xml b/vcloud/bluelock/src/test/resources/log4j.xml new file mode 100644 index 0000000000..44c7ce6d65 --- /dev/null +++ b/vcloud/bluelock/src/test/resources/log4j.xml @@ -0,0 +1,145 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/vcloud/core/src/main/java/org/jclouds/vcloud/compute/config/VCloudComputeServiceContextModule.java b/vcloud/core/src/main/java/org/jclouds/vcloud/compute/config/VCloudComputeServiceContextModule.java index c96e57aba2..4f97aa0054 100755 --- a/vcloud/core/src/main/java/org/jclouds/vcloud/compute/config/VCloudComputeServiceContextModule.java +++ b/vcloud/core/src/main/java/org/jclouds/vcloud/compute/config/VCloudComputeServiceContextModule.java @@ -72,8 +72,6 @@ import org.jclouds.vcloud.VCloudMediaType; import org.jclouds.vcloud.compute.BaseVCloudComputeClient; import org.jclouds.vcloud.compute.VCloudComputeClient; import org.jclouds.vcloud.config.VCloudContextModule; -import org.jclouds.vcloud.domain.Catalog; -import org.jclouds.vcloud.domain.CatalogItem; import org.jclouds.vcloud.domain.NamedResource; import org.jclouds.vcloud.domain.Task; import org.jclouds.vcloud.domain.VApp; @@ -302,36 +300,33 @@ public class VCloudComputeServiceContextModule extends VCloudContextModule { // TODO multi-VDC final Set images = Sets.newHashSet(); holder.logger.debug(">> providing images"); - Catalog response = client.getDefaultCatalog(); + Map resources = client.getDefaultVDC().getResourceEntities(); Map> responses = Maps.newHashMap(); - for (final NamedResource resource : response.values()) { - if (resource.getType().equals(VCloudMediaType.CATALOGITEM_XML)) { - final CatalogItem item = client.getCatalogItem(resource.getId()); - if (item.getEntity().getType().equals(VCloudMediaType.VAPPTEMPLATE_XML)) { - responses.put(item.getName(), ConcurrentUtils.makeListenable(executor - .submit(new Callable() { - @Override - public Void call() throws Exception { - OsFamily myOs = null; - for (OsFamily os : OsFamily.values()) { - if (resource.getName().toLowerCase().replaceAll("\\s", "") - .indexOf(os.toString()) != -1) { - myOs = os; - } + for (final NamedResource resource : resources.values()) { + if (resource.getType().equals(VCloudMediaType.VAPPTEMPLATE_XML)) { + responses.put(resource.getName(), ConcurrentUtils.makeListenable(executor + .submit(new Callable() { + @Override + public Void call() throws Exception { + OsFamily myOs = null; + for (OsFamily os : OsFamily.values()) { + if (resource.getName().toLowerCase().replaceAll("\\s", "").indexOf( + os.toString()) != -1) { + myOs = os; } - Architecture arch = resource.getName().indexOf("64") == -1 ? Architecture.X86_32 - : Architecture.X86_64; - VAppTemplate template = client.getVAppTemplate(item.getEntity() - .getId()); - images.add(new ImageImpl(resource.getId(), template.getName(), vDC - .getId(), template.getLocation(), ImmutableMap - . of(), template.getDescription(), "", myOs, - template.getName(), arch)); - return null; } - }), executor)); - } + Architecture arch = resource.getName().indexOf("64") == -1 ? Architecture.X86_32 + : Architecture.X86_64; + VAppTemplate template = client.getVAppTemplate(resource.getId()); + images.add(new ImageImpl(resource.getId(), template.getName(), vDC + .getId(), template.getLocation(), ImmutableMap + . of(), template.getDescription(), "", myOs, + template.getName(), arch)); + return null; + } + }), executor)); + } } diff --git a/vcloud/core/src/main/java/org/jclouds/vcloud/config/VCloudRestClientModule.java b/vcloud/core/src/main/java/org/jclouds/vcloud/config/VCloudRestClientModule.java index a263bc263d..70694f0ea1 100644 --- a/vcloud/core/src/main/java/org/jclouds/vcloud/config/VCloudRestClientModule.java +++ b/vcloud/core/src/main/java/org/jclouds/vcloud/config/VCloudRestClientModule.java @@ -244,7 +244,7 @@ public class VCloudRestClientModule extends AbstractModule { @Provides @Catalog @Singleton - protected URI provideCatalog(Organization org) { + protected URI provideCatalog(Organization org, @Named(PROPERTY_VCLOUD_USER) String user) { return Iterables.get(org.getCatalogs().values(), 0).getLocation(); } diff --git a/vcloud/core/src/test/java/org/jclouds/vcloud/VCloudClientLiveTest.java b/vcloud/core/src/test/java/org/jclouds/vcloud/VCloudClientLiveTest.java index ce81ea0edd..181d6e5236 100644 --- a/vcloud/core/src/test/java/org/jclouds/vcloud/VCloudClientLiveTest.java +++ b/vcloud/core/src/test/java/org/jclouds/vcloud/VCloudClientLiveTest.java @@ -66,7 +66,6 @@ public class VCloudClientLiveTest { assertNotNull(response.getId()); assertNotNull(response.getName()); assertNotNull(response.getLocation()); - assert response.size() > 0; assertEquals(connection.getCatalog(response.getId()), response); } diff --git a/vcloud/core/src/test/java/org/jclouds/vcloud/VCloudLoginLiveTest.java b/vcloud/core/src/test/java/org/jclouds/vcloud/VCloudLoginLiveTest.java index a67bd89ace..5a5f0ddb56 100755 --- a/vcloud/core/src/test/java/org/jclouds/vcloud/VCloudLoginLiveTest.java +++ b/vcloud/core/src/test/java/org/jclouds/vcloud/VCloudLoginLiveTest.java @@ -20,10 +20,9 @@ package org.jclouds.vcloud; import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.util.concurrent.Executors.sameThreadExecutor; +import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_ENDPOINT; import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_KEY; -import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_SESSIONINTERVAL; import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_USER; -import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_VERSION; import static org.testng.Assert.assertNotNull; import java.io.UnsupportedEncodingException; @@ -34,7 +33,6 @@ import java.util.concurrent.TimeUnit; import javax.inject.Named; import javax.inject.Singleton; -import org.jclouds.PropertiesBuilder; import org.jclouds.concurrent.config.ExecutorServiceModule; import org.jclouds.encryption.EncryptionService; import org.jclouds.http.RequiresHttp; @@ -49,7 +47,6 @@ import org.jclouds.rest.internal.RestContextImpl; import org.jclouds.vcloud.endpoints.VCloudLogin; import org.jclouds.vcloud.internal.VCloudLoginAsyncClient; import org.jclouds.vcloud.internal.VCloudLoginAsyncClient.VCloudSession; -import org.jclouds.vcloud.reference.VCloudConstants; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -69,11 +66,6 @@ public class VCloudLoginLiveTest { @RequiresHttp @ConfiguresRestClient private static final class VCloudLoginRestClientModule extends AbstractModule { - final String endpoint; - - public VCloudLoginRestClientModule(String endpoint) { - this.endpoint = endpoint; - } @SuppressWarnings("unused") @Provides @@ -91,10 +83,19 @@ public class VCloudLoginLiveTest { return new BasicAuthentication(user, key, encryptionService); } + @SuppressWarnings("unused") + @Provides + @Singleton + @VCloudLogin + URI provideUri(@Named(PROPERTY_VCLOUD_ENDPOINT) String endpoint) { + return URI.create(endpoint); + } + @Override protected void configure() { - bind(URI.class).annotatedWith(VCloudLogin.class).toInstance(URI.create(endpoint)); + } + } private final class VCloudLoginContextModule extends AbstractModule { @@ -129,43 +130,23 @@ public class VCloudLoginLiveTest { @BeforeClass void setupFactory() { - final String endpoint = checkNotNull(System.getProperty("jclouds.test.endpoint"), + String endpoint = checkNotNull(System.getProperty("jclouds.test.endpoint"), "jclouds.test.endpoint") + "/v0.8/login"; - final String account = checkNotNull(System.getProperty("jclouds.test.user"), - "jclouds.test.user"); - final String key = checkNotNull(System.getProperty("jclouds.test.key"), "jclouds.test.key"); - + String account = checkNotNull(System.getProperty("jclouds.test.user"), "jclouds.test.user"); + String key = checkNotNull(System.getProperty("jclouds.test.key"), "jclouds.test.key"); context = new RestContextBuilder( new TypeLiteral() { }, new TypeLiteral() { - }, new PropertiesBuilder() { - - @Override - public PropertiesBuilder withCredentials(String account, String key) { - return null; - } - - @Override - public PropertiesBuilder withEndpoint(URI endpoint) { - return null; - } - }.build()) { + }, new VCloudPropertiesBuilder(URI.create(endpoint), account, key).build()) { public void addContextModule(List modules) { - modules.add(new VCloudLoginContextModule()); } @Override protected void addClientModule(List modules) { - properties.setProperty(VCloudConstants.PROPERTY_VCLOUD_ENDPOINT, checkNotNull(endpoint, - "endpoint").toString()); - properties.setProperty(PROPERTY_VCLOUD_VERSION, "0.8"); - properties.setProperty(PROPERTY_VCLOUD_USER, checkNotNull(account, "user")); - properties.setProperty(PROPERTY_VCLOUD_KEY, checkNotNull(key, "key")); - properties.setProperty(PROPERTY_VCLOUD_SESSIONINTERVAL, "4"); - modules.add(new VCloudLoginRestClientModule(endpoint)); + modules.add(new VCloudLoginRestClientModule()); } }.withModules(new Log4JLoggingModule(), diff --git a/vcloud/core/src/test/java/org/jclouds/vcloud/VCloudVersionsLiveTest.java b/vcloud/core/src/test/java/org/jclouds/vcloud/VCloudVersionsLiveTest.java index 629445a6cb..4537c92016 100644 --- a/vcloud/core/src/test/java/org/jclouds/vcloud/VCloudVersionsLiveTest.java +++ b/vcloud/core/src/test/java/org/jclouds/vcloud/VCloudVersionsLiveTest.java @@ -20,14 +20,15 @@ package org.jclouds.vcloud; import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.util.concurrent.Executors.sameThreadExecutor; +import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_ENDPOINT; import static org.testng.Assert.assertNotNull; import java.net.URI; import java.util.List; -import java.util.Properties; import java.util.SortedMap; import java.util.concurrent.TimeUnit; +import javax.inject.Named; import javax.inject.Singleton; import org.jclouds.concurrent.config.ExecutorServiceModule; @@ -67,9 +68,16 @@ public class VCloudVersionsLiveTest { return factory.create(VCloudVersionsAsyncClient.class); } + @SuppressWarnings("unused") + @Provides + @Singleton + @VCloud + URI provideUri(@Named(PROPERTY_VCLOUD_ENDPOINT) String endpoint) { + return URI.create(endpoint); + } + @Override protected void configure() { - bind(URI.class).annotatedWith(VCloud.class).toInstance(URI.create(endpoint)); } } @@ -90,9 +98,6 @@ public class VCloudVersionsLiveTest { } } - static String endpoint = checkNotNull(System.getProperty("jclouds.test.endpoint"), - "jclouds.test.endpoint"); - private RestContext context; @Test @@ -108,10 +113,14 @@ public class VCloudVersionsLiveTest { @BeforeClass void setupFactory() { + String endpoint = checkNotNull(System.getProperty("jclouds.test.endpoint"), + "jclouds.test.endpoint"); + String account = checkNotNull(System.getProperty("jclouds.test.user"), "jclouds.test.user"); + String key = checkNotNull(System.getProperty("jclouds.test.key"), "jclouds.test.key"); context = new RestContextBuilder( new TypeLiteral() { }, new TypeLiteral() { - }, new Properties()) { + }, new VCloudPropertiesBuilder(URI.create(endpoint), account, key).build()) { public void addContextModule(List modules) { diff --git a/vcloud/core/src/test/java/org/jclouds/vcloud/compute/PropertiesTest.java b/vcloud/core/src/test/java/org/jclouds/vcloud/compute/PropertiesTest.java index 66aebef007..4b815050a3 100644 --- a/vcloud/core/src/test/java/org/jclouds/vcloud/compute/PropertiesTest.java +++ b/vcloud/core/src/test/java/org/jclouds/vcloud/compute/PropertiesTest.java @@ -45,8 +45,8 @@ public class PropertiesTest { } public void test() { - assertEquals(properties.getProperty("vcloud.contextbuilder"), - VCloudContextBuilder.class.getName()); + assertEquals(properties.getProperty("vcloud.contextbuilder"), VCloudContextBuilder.class + .getName()); assertEquals(properties.getProperty("vcloud.propertiesbuilder"), VCloudPropertiesBuilder.class.getName()); } diff --git a/vcloud/core/src/test/java/org/jclouds/vcloud/compute/VCloudComputeServiceLiveTest.java b/vcloud/core/src/test/java/org/jclouds/vcloud/compute/VCloudComputeServiceLiveTest.java index b901ba5332..29486fec77 100644 --- a/vcloud/core/src/test/java/org/jclouds/vcloud/compute/VCloudComputeServiceLiveTest.java +++ b/vcloud/core/src/test/java/org/jclouds/vcloud/compute/VCloudComputeServiceLiveTest.java @@ -45,10 +45,5 @@ public class VCloudComputeServiceLiveTest extends BaseComputeServiceLiveTest { @SuppressWarnings("unused") RestContext tmContext = new ComputeServiceContextFactory() .createContext(service, user, password).getProviderSpecificContext(); - - BaseVCloudComputeClient computeService = BaseVCloudComputeClient.class.cast(client); - - @SuppressWarnings("unused") - VCloudComputeClient computeClient = VCloudComputeClient.class.cast(computeService); } } \ No newline at end of file diff --git a/vcloud/pom.xml b/vcloud/pom.xml index 82aaba8a71..890095fbd5 100644 --- a/vcloud/pom.xml +++ b/vcloud/pom.xml @@ -35,6 +35,7 @@ core terremark hostingdotcom + bluelock