Issue 176: initial bluelock support

This commit is contained in:
Adrian Cole 2010-02-21 13:10:26 -08:00
parent f2fb83abaf
commit ea8bb3f454
20 changed files with 781 additions and 79 deletions

View File

@ -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
# bluelock.endpoint=https://express3.bluelock.com/api

View File

@ -0,0 +1,24 @@
====
Copyright (C) 2009 Cloud Conscious, LLC. <info@cloudconscious.com>
====================================================================
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.

60
vcloud/bluelock/pom.xml Normal file
View File

@ -0,0 +1,60 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (C) 2009 Cloud Conscious, LLC. <info@cloudconscious.com>
====================================================================
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.
====================================================================
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.jclouds</groupId>
<artifactId>jclouds-vcloud-project</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<groupId>org.jclouds</groupId>
<artifactId>jclouds-bluelock</artifactId>
<name>jclouds bluelock Components Core</name>
<description>jclouds core components to access bluelock</description>
<properties>
<jclouds.test.user>${jclouds.bluelock.user}</jclouds.test.user>
<jclouds.test.key>${jclouds.bluelock.password}</jclouds.test.key>
</properties>
<scm>
<connection>scm:svn:http://jclouds.googlecode.com/svn/trunk/vcloud/bluelock</connection>
<developerConnection>scm:svn:https://jclouds.googlecode.com/svn/trunk/vcloud/bluelock</developerConnection>
<url>http://jclouds.googlecode.com/svn/trunk/vcloud/bluelock</url>
</scm>
<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>jclouds-vcloud</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>jclouds-vcloud</artifactId>
<version>${project.version}</version>
<type>test-jar</type>
<scope>test</scope>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,57 @@
/**
*
* Copyright (C) 2009 Cloud Conscious, LLC. <info@cloudconscious.com>
*
* ====================================================================
* 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.
* <p/>
* Note that Threadsafe objects will be bound as singletons to the Injector or Context provided.
* <p/>
* <p/>
* If no <code>Module</code>s 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<Module> modules) {
modules.add(new BlueLockVCloudRestClientModule());
}
}

View File

@ -0,0 +1,69 @@
/**
*
* Copyright (C) 2009 Cloud Conscious, LLC. <info@cloudconscious.com>
*
* ====================================================================
* 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.
* <p/>
* Note that Threadsafe objects will be bound as singletons to the Injector or Context provided.
* <p/>
* <p/>
* If no <code>Module</code>s 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();
}
}

View File

@ -0,0 +1,48 @@
/**
*
* Copyright (C) 2009 Cloud Conscious, LLC. <info@cloudconscious.com>
*
* ====================================================================
* 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);
}
}

View File

@ -0,0 +1,37 @@
/**
*
* Copyright (C) 2009 Cloud Conscious, LLC. <info@cloudconscious.com>
*
* ====================================================================
* 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();
}
}

View File

@ -0,0 +1,76 @@
/**
*
* Copyright (C) 2009 Cloud Conscious, LLC. <info@cloudconscious.com>
*
* ====================================================================
* 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<NamedResource>() {
@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<NamedResource>() {
@Override
public boolean apply(NamedResource input) {
return input.getName().startsWith(user);
}
})).getLocation();
}
}

View File

@ -0,0 +1,67 @@
/**
*
* Copyright (C) 2009 Cloud Conscious, LLC. <info@cloudconscious.com>
*
* ====================================================================
* 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();
}
}

View File

@ -0,0 +1,83 @@
/**
*
* Copyright (C) 2009 Cloud Conscious, LLC. <info@cloudconscious.com>
*
* ====================================================================
* 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<String, ? extends Image> 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();
}
}

View File

@ -0,0 +1,54 @@
/**
*
* Copyright (C) 2009 Cloud Conscious, LLC. <info@cloudconscious.com>
*
* ====================================================================
* 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());
}
}

View File

@ -0,0 +1,145 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (C) 2009 Cloud Conscious, LLC.
<info@cloudconscious.com>
====================================================================
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.
====================================================================
-->
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<!--
For more configuration infromation and examples see the Apache
Log4j website: http://logging.apache.org/log4j/
-->
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/"
debug="false">
<!-- A time/date based rolling appender -->
<appender name="WIREFILE" class="org.apache.log4j.DailyRollingFileAppender">
<param name="File" value="target/test-data/jclouds-wire.log" />
<param name="Append" value="true" />
<!-- Rollover at midnight each day -->
<param name="DatePattern" value="'.'yyyy-MM-dd" />
<param name="Threshold" value="TRACE" />
<layout class="org.apache.log4j.PatternLayout">
<!-- The default pattern: Date Priority [Category] Message\n -->
<param name="ConversionPattern" value="%d %-5p [%c] (%t) %m%n" />
<!--
The full pattern: Date MS Priority [Category]
(Thread:NDC) Message\n <param name="ConversionPattern"
value="%d %-5r %-5p [%c] (%t:%x) %m%n"/>
-->
</layout>
</appender>
<!-- A time/date based rolling appender -->
<appender name="FILE" class="org.apache.log4j.DailyRollingFileAppender">
<param name="File" value="target/test-data/jclouds.log" />
<param name="Append" value="true" />
<!-- Rollover at midnight each day -->
<param name="DatePattern" value="'.'yyyy-MM-dd" />
<param name="Threshold" value="TRACE" />
<layout class="org.apache.log4j.PatternLayout">
<!-- The default pattern: Date Priority [Category] Message\n -->
<param name="ConversionPattern" value="%d %-5p [%c] (%t) %m%n" />
<!--
The full pattern: Date MS Priority [Category]
(Thread:NDC) Message\n <param name="ConversionPattern"
value="%d %-5r %-5p [%c] (%t:%x) %m%n"/>
-->
</layout>
</appender>
<!-- A time/date based rolling appender -->
<appender name="COMPUTEFILE" class="org.apache.log4j.DailyRollingFileAppender">
<param name="File" value="target/test-data/jclouds-compute.log" />
<param name="Append" value="true" />
<!-- Rollover at midnight each day -->
<param name="DatePattern" value="'.'yyyy-MM-dd" />
<param name="Threshold" value="TRACE" />
<layout class="org.apache.log4j.PatternLayout">
<!-- The default pattern: Date Priority [Category] Message\n -->
<param name="ConversionPattern" value="%d %-5p [%c] (%t) %m%n" />
<!--
The full pattern: Date MS Priority [Category]
(Thread:NDC) Message\n <param name="ConversionPattern"
value="%d %-5r %-5p [%c] (%t:%x) %m%n"/>
-->
</layout>
</appender>
<appender name="ASYNCCOMPUTE" class="org.apache.log4j.AsyncAppender">
<appender-ref ref="COMPUTEFILE" />
</appender>
<appender name="ASYNC" class="org.apache.log4j.AsyncAppender">
<appender-ref ref="FILE" />
</appender>
<appender name="ASYNCWIRE" class="org.apache.log4j.AsyncAppender">
<appender-ref ref="WIREFILE" />
</appender>
<!-- ================ -->
<!-- Limit categories -->
<!-- ================ -->
<category name="org.jclouds">
<priority value="DEBUG" />
<appender-ref ref="ASYNC" />
</category>
<category name="jclouds.headers">
<priority value="DEBUG" />
<appender-ref ref="ASYNCWIRE" />
</category>
<category name="org.jclouds.predicates.SocketOpen">
<priority value="TRACE" />
<appender-ref ref="ASYNCWIRE" />
</category>
<category name="jclouds.compute">
<priority value="TRACE" />
<appender-ref ref="ASYNCCOMPUTE" />
</category>
<category name="jclouds.wire">
<priority value="DEBUG" />
<appender-ref ref="ASYNCWIRE" />
</category>
<!-- ======================= -->
<!-- Setup the Root category -->
<!-- ======================= -->
<root>
<priority value="WARN" />
</root>
</log4j:configuration>

View File

@ -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,28 +300,25 @@ public class VCloudComputeServiceContextModule extends VCloudContextModule {
// TODO multi-VDC
final Set<Image> images = Sets.newHashSet();
holder.logger.debug(">> providing images");
Catalog response = client.getDefaultCatalog();
Map<String, NamedResource> resources = client.getDefaultVDC().getResourceEntities();
Map<String, ListenableFuture<Void>> 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
for (final NamedResource resource : resources.values()) {
if (resource.getType().equals(VCloudMediaType.VAPPTEMPLATE_XML)) {
responses.put(resource.getName(), ConcurrentUtils.makeListenable(executor
.submit(new Callable<Void>() {
@Override
public Void call() throws Exception {
OsFamily myOs = null;
for (OsFamily os : OsFamily.values()) {
if (resource.getName().toLowerCase().replaceAll("\\s", "")
.indexOf(os.toString()) != -1) {
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());
VAppTemplate template = client.getVAppTemplate(resource.getId());
images.add(new ImageImpl(resource.getId(), template.getName(), vDC
.getId(), template.getLocation(), ImmutableMap
.<String, String> of(), template.getDescription(), "", myOs,
@ -331,7 +326,7 @@ public class VCloudComputeServiceContextModule extends VCloudContextModule {
return null;
}
}), executor));
}
}
}

View File

@ -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();
}

View File

@ -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);
}

View File

@ -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<VCloudLoginAsyncClient, VCloudLoginAsyncClient>(
new TypeLiteral<VCloudLoginAsyncClient>() {
}, new TypeLiteral<VCloudLoginAsyncClient>() {
}, 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<Module> modules) {
modules.add(new VCloudLoginContextModule());
}
@Override
protected void addClientModule(List<Module> 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(),

View File

@ -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<VCloudVersionsAsyncClient, VCloudVersionsAsyncClient> 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<VCloudVersionsAsyncClient, VCloudVersionsAsyncClient>(
new TypeLiteral<VCloudVersionsAsyncClient>() {
}, new TypeLiteral<VCloudVersionsAsyncClient>() {
}, new Properties()) {
}, new VCloudPropertiesBuilder(URI.create(endpoint), account, key).build()) {
public void addContextModule(List<Module> modules) {

View File

@ -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());
}

View File

@ -45,10 +45,5 @@ public class VCloudComputeServiceLiveTest extends BaseComputeServiceLiveTest {
@SuppressWarnings("unused")
RestContext<VCloudAsyncClient, VCloudClient> tmContext = new ComputeServiceContextFactory()
.createContext(service, user, password).getProviderSpecificContext();
BaseVCloudComputeClient computeService = BaseVCloudComputeClient.class.cast(client);
@SuppressWarnings("unused")
VCloudComputeClient computeClient = VCloudComputeClient.class.cast(computeService);
}
}

View File

@ -35,6 +35,7 @@
<module>core</module>
<module>terremark</module>
<module>hostingdotcom</module>
<module>bluelock</module>
</modules>
<dependencies>
<dependency>