Issue 542: updated terremark eCloud implementation to 2.8 version of Org and added Tag and DataCenter queries

This commit is contained in:
Adrian Cole 2011-07-17 18:44:44 +10:00
parent bbcf87265e
commit f81bb95ab0
59 changed files with 2333 additions and 377 deletions

View File

@ -21,6 +21,7 @@ package org.jclouds.vcloud.config;
import static com.google.common.base.Throwables.propagate; import static com.google.common.base.Throwables.propagate;
import static org.jclouds.Constants.PROPERTY_SESSION_INTERVAL; import static org.jclouds.Constants.PROPERTY_SESSION_INTERVAL;
import java.util.Map;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import javax.inject.Named; import javax.inject.Named;
@ -43,7 +44,6 @@ import com.google.common.base.Supplier;
import com.google.inject.Provides; import com.google.inject.Provides;
import com.google.inject.TypeLiteral; import com.google.inject.TypeLiteral;
/** /**
* Configures the VCloud authentication service connection, including logging * Configures the VCloud authentication service connection, including logging
* and http transport. * and http transport.
@ -59,6 +59,11 @@ public abstract class BaseVCloudExpressRestClientModule<S extends VCloudExpressC
super(syncClientType, asyncClientType); super(syncClientType, asyncClientType);
} }
public BaseVCloudExpressRestClientModule(Class<S> syncClientType, Class<A> asyncClientType,
Map<Class<?>, Class<?>> delegateMap) {
super(syncClientType, asyncClientType, delegateMap);
}
@Override @Override
protected void configure() { protected void configure() {
bind(new TypeLiteral<Function<Iterable<? extends CatalogItem>, Iterable<? extends VCloudExpressVAppTemplate>>>() { bind(new TypeLiteral<Function<Iterable<? extends CatalogItem>, Iterable<? extends VCloudExpressVAppTemplate>>>() {

View File

@ -57,9 +57,11 @@ import org.jclouds.rest.functions.ReturnVoidOnNotFoundOr404;
import org.jclouds.vcloud.VCloudExpressAsyncClient; import org.jclouds.vcloud.VCloudExpressAsyncClient;
import org.jclouds.vcloud.VCloudExpressClient; import org.jclouds.vcloud.VCloudExpressClient;
import org.jclouds.vcloud.domain.Catalog; import org.jclouds.vcloud.domain.Catalog;
import org.jclouds.vcloud.domain.ReferenceType;
import org.jclouds.vcloud.domain.Task; import org.jclouds.vcloud.domain.Task;
import org.jclouds.vcloud.domain.VCloudExpressVApp; import org.jclouds.vcloud.domain.VCloudExpressVApp;
import org.jclouds.vcloud.domain.VDC; import org.jclouds.vcloud.domain.VDC;
import org.jclouds.vcloud.endpoints.Org;
import org.jclouds.vcloud.filters.SetVCloudTokenCookie; import org.jclouds.vcloud.filters.SetVCloudTokenCookie;
import org.jclouds.vcloud.functions.OrgNameAndVDCNameToEndpoint; import org.jclouds.vcloud.functions.OrgNameAndVDCNameToEndpoint;
import org.jclouds.vcloud.functions.OrgNameCatalogNameItemNameToEndpoint; import org.jclouds.vcloud.functions.OrgNameCatalogNameItemNameToEndpoint;
@ -96,6 +98,7 @@ import org.jclouds.vcloud.xml.VCloudExpressCatalogHandler;
import org.jclouds.vcloud.xml.VCloudExpressVAppHandler; import org.jclouds.vcloud.xml.VCloudExpressVAppHandler;
import com.google.common.util.concurrent.ListenableFuture; import com.google.common.util.concurrent.ListenableFuture;
import com.google.inject.Provides;
/** /**
* Provides access to VCloud resources via their REST API. * Provides access to VCloud resources via their REST API.
@ -106,6 +109,14 @@ import com.google.common.util.concurrent.ListenableFuture;
*/ */
@RequestFilters(SetVCloudTokenCookie.class) @RequestFilters(SetVCloudTokenCookie.class)
public interface TerremarkVCloudAsyncClient extends VCloudExpressAsyncClient { public interface TerremarkVCloudAsyncClient extends VCloudExpressAsyncClient {
/**
*
* @return a listing of all orgs that the current user has access to.
*/
@Provides
@Org
Iterable<ReferenceType> listOrgs();
/** /**
* @see VCloudExpressClient#getCatalogItemInOrg * @see VCloudExpressClient#getCatalogItemInOrg
*/ */

View File

@ -26,8 +26,10 @@ import javax.annotation.Nullable;
import org.jclouds.concurrent.Timeout; import org.jclouds.concurrent.Timeout;
import org.jclouds.vcloud.VCloudExpressClient; import org.jclouds.vcloud.VCloudExpressClient;
import org.jclouds.vcloud.domain.ReferenceType;
import org.jclouds.vcloud.domain.Task; import org.jclouds.vcloud.domain.Task;
import org.jclouds.vcloud.domain.VCloudExpressVApp; 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.CustomizationParameters;
import org.jclouds.vcloud.terremark.domain.InternetService; import org.jclouds.vcloud.terremark.domain.InternetService;
import org.jclouds.vcloud.terremark.domain.KeyPair; 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.AddInternetServiceOptions;
import org.jclouds.vcloud.terremark.options.AddNodeOptions; import org.jclouds.vcloud.terremark.options.AddNodeOptions;
import com.google.inject.Provides;
/** /**
* Provides access to VCloud resources via their REST API. * Provides access to VCloud resources via their REST API.
* <p/> * <p/>
@ -50,6 +54,14 @@ import org.jclouds.vcloud.terremark.options.AddNodeOptions;
*/ */
@Timeout(duration = 300, timeUnit = TimeUnit.SECONDS) @Timeout(duration = 300, timeUnit = TimeUnit.SECONDS)
public interface TerremarkVCloudClient extends VCloudExpressClient { public interface TerremarkVCloudClient extends VCloudExpressClient {
/**
*
* @return a listing of all orgs that the current user has access to.
*/
@Provides
@Org
Iterable<ReferenceType> listOrgs();
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */

View File

@ -17,12 +17,11 @@
* ==================================================================== * ====================================================================
*/ */
package org.jclouds.vcloud.terremark.config; package org.jclouds.vcloud.terremark.config;
import static org.jclouds.Constants.PROPERTY_SESSION_INTERVAL; import static org.jclouds.Constants.PROPERTY_SESSION_INTERVAL;
import java.io.IOException; import java.io.IOException;
import java.util.Map; import java.util.Map;
import javax.inject.Inject; import javax.inject.Inject;
import javax.inject.Named; import javax.inject.Named;
import javax.inject.Singleton; import javax.inject.Singleton;
@ -38,7 +37,7 @@ import org.jclouds.vcloud.domain.ReferenceType;
import org.jclouds.vcloud.domain.VCloudSession; import org.jclouds.vcloud.domain.VCloudSession;
import org.jclouds.vcloud.terremark.TerremarkVCloudAsyncClient; import org.jclouds.vcloud.terremark.TerremarkVCloudAsyncClient;
import org.jclouds.vcloud.terremark.TerremarkVCloudClient; 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 org.jclouds.vcloud.terremark.handlers.ParseTerremarkVCloudErrorFromHttpResponse;
import com.google.common.base.Function; import com.google.common.base.Function;
@ -53,6 +52,11 @@ public abstract class TerremarkRestClientModule<S extends TerremarkVCloudClient,
super(syncClientType, asyncClientType); super(syncClientType, asyncClientType);
} }
public TerremarkRestClientModule(Class<S> syncClientType, Class<A> asyncClientType,
Map<Class<?>, Class<?>> delegateMap) {
super(syncClientType, asyncClientType, delegateMap);
}
@Singleton @Singleton
@Provides @Provides
@Named("CreateInternetService") @Named("CreateInternetService")
@ -96,7 +100,7 @@ public abstract class TerremarkRestClientModule<S extends TerremarkVCloudClient,
@Override @Override
public ReferenceType apply(ReferenceType from) { public ReferenceType apply(ReferenceType from) {
return client.findOrgNamed(from.getName()).getKeysList(); return client.findOrgNamed(from.getName()).getKeys();
} }
}); });
@ -105,7 +109,7 @@ public abstract class TerremarkRestClientModule<S extends TerremarkVCloudClient,
@Provides @Provides
@Singleton @Singleton
@KeysList @Keys
protected Supplier<Map<String, ReferenceType>> provideOrgToKeysListCache( protected Supplier<Map<String, ReferenceType>> provideOrgToKeysListCache(
@Named(PROPERTY_SESSION_INTERVAL) long seconds, final OrgNameToKeysListSupplier supplier) { @Named(PROPERTY_SESSION_INTERVAL) long seconds, final OrgNameToKeysListSupplier supplier) {
return new MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier<Map<String, ReferenceType>>(authException, return new MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier<Map<String, ReferenceType>>(authException,

View File

@ -0,0 +1,131 @@
/**
*
* Copyright (C) 2011 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.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 + "]";
}
}

View File

@ -83,9 +83,8 @@ public class InternetService implements Comparable<InternetService> {
@Override @Override
public String toString() { public String toString() {
return "InternetService [description=" + description + ", enabled=" + enabled + ", id=" + id + ", name=" return "[description=" + description + ", enabled=" + enabled + ", id=" + id + ", name=" + name + ", port="
+ name + ", port=" + port + ", protocol=" + protocol + ", publicIpAddress=" + publicIpAddress + port + ", protocol=" + protocol + ", publicIpAddress=" + publicIpAddress + ", timeout=" + timeout + "]";
+ ", timeout=" + timeout + "]";
} }
@Override @Override

View File

@ -18,10 +18,12 @@
*/ */
package org.jclouds.vcloud.terremark.domain; 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.Org;
import org.jclouds.vcloud.domain.ReferenceType;
import org.jclouds.vcloud.terremark.domain.internal.TerremarkOrgImpl; 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; import com.google.inject.ImplementedBy;
@ -31,8 +33,26 @@ import com.google.inject.ImplementedBy;
@org.jclouds.vcloud.endpoints.Org @org.jclouds.vcloud.endpoints.Org
@ImplementedBy(TerremarkOrgImpl.class) @ImplementedBy(TerremarkOrgImpl.class)
public interface TerremarkOrg extends Org { public interface TerremarkOrg extends Org {
/**
@KeysList *
* @see #getKeys
*/
@Deprecated
ReferenceType getKeysList(); ReferenceType getKeysList();
@Keys
ReferenceType getKeys();
/**
* there are multiple tasks lists in a terremark org
*
* @see #getTasksLists
*/
@Deprecated
ReferenceType getTasksList();
/**
*/
Map<String, ReferenceType> getTasksLists();
} }

View File

@ -18,17 +18,19 @@
*/ */
package org.jclouds.vcloud.terremark.domain.internal; package org.jclouds.vcloud.terremark.domain.internal;
import static com.google.common.base.Preconditions.checkNotNull;
import java.net.URI; import java.net.URI;
import java.util.Map; import java.util.Map;
import javax.annotation.Nullable;
import org.jclouds.vcloud.domain.ReferenceType; import org.jclouds.vcloud.domain.ReferenceType;
import org.jclouds.vcloud.domain.Task; import org.jclouds.vcloud.domain.Task;
import org.jclouds.vcloud.domain.internal.OrgImpl; import org.jclouds.vcloud.domain.internal.OrgImpl;
import org.jclouds.vcloud.terremark.domain.TerremarkOrg; import org.jclouds.vcloud.terremark.domain.TerremarkOrg;
import com.google.common.collect.ImmutableList; 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 * Locations of resources in a Terremark vCloud
@ -39,12 +41,15 @@ import com.google.common.collect.ImmutableList;
public class TerremarkOrgImpl extends OrgImpl implements TerremarkOrg { public class TerremarkOrgImpl extends OrgImpl implements TerremarkOrg {
private final ReferenceType keysList; private final ReferenceType keysList;
private final ImmutableMap<String, ReferenceType> tasksLists;
public TerremarkOrgImpl(String name, String type, URI id, String description, Map<String, ReferenceType> catalogs, public TerremarkOrgImpl(String name, String type, URI id, String description, Map<String, ReferenceType> catalogs,
Map<String, ReferenceType> vdcs, Map<String, ReferenceType> networks, @Nullable ReferenceType tasksList, Map<String, ReferenceType> vdcs, Map<String, ReferenceType> networks, Map<String, ReferenceType> tasksLists,
ReferenceType keysList) { ReferenceType keysList) {
super(name, type, id, name, description, catalogs, vdcs, networks, tasksList, ImmutableList.<Task> of()); super(name, type, id, name, description, catalogs, vdcs, networks, Iterables.get(tasksLists.values(), 0),
this.keysList = keysList; ImmutableList.<Task> of());
this.tasksLists = ImmutableMap.copyOf(checkNotNull(tasksLists, "tasksLists"));
this.keysList = checkNotNull(keysList, "keysList");
} }
@Override @Override
@ -52,4 +57,14 @@ public class TerremarkOrgImpl extends OrgImpl implements TerremarkOrg {
return keysList; return keysList;
} }
@Override
public Map<String, ReferenceType> getTasksLists() {
return tasksLists;
}
@Override
public ReferenceType getKeys() {
return keysList;
}
} }

View File

@ -45,9 +45,6 @@ public class TerremarkVDCImpl extends VDCImpl implements TerremarkVDC {
private final ReferenceType publicIps; private final ReferenceType publicIps;
private final ReferenceType internetServices; private final ReferenceType internetServices;
/** The serialVersionUID */
private static final long serialVersionUID = 8464716396538298809L;
public TerremarkVDCImpl(String name, String type, URI id, VDCStatus status, ReferenceType org, public TerremarkVDCImpl(String name, String type, URI id, VDCStatus status, ReferenceType org,
@Nullable String description, Iterable<Task> tasks, AllocationModel allocationModel, @Nullable String description, Iterable<Task> tasks, AllocationModel allocationModel,
@Nullable Capacity storageCapacity, @Nullable Capacity cpuCapacity, @Nullable Capacity memoryCapacity, @Nullable Capacity storageCapacity, @Nullable Capacity cpuCapacity, @Nullable Capacity memoryCapacity,

View File

@ -0,0 +1,39 @@
/**
*
* Copyright (C) 2011 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.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 {
}

View File

@ -34,6 +34,6 @@ import javax.inject.Qualifier;
@Retention(value = RetentionPolicy.RUNTIME) @Retention(value = RetentionPolicy.RUNTIME)
@Target(value = { ElementType.TYPE, ElementType.FIELD, ElementType.PARAMETER, ElementType.METHOD }) @Target(value = { ElementType.TYPE, ElementType.FIELD, ElementType.PARAMETER, ElementType.METHOD })
@Qualifier @Qualifier
public @interface KeysList { public @interface Keys {
} }

View File

@ -0,0 +1,39 @@
/**
*
* Copyright (C) 2011 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.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 {
}

View File

@ -0,0 +1,39 @@
/**
*
* Copyright (C) 2011 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.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 {
}

View File

@ -0,0 +1,65 @@
/**
*
* Copyright (C) 2011 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.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<Object, URI> {
protected final Supplier<Map<String, ? extends Org>> orgMap;
protected final URI defaultOrg;
public OrgURIToEndpoint(Supplier<Map<String, ? extends Org>> orgMap, @org.jclouds.vcloud.endpoints.Org URI defaultUri) {
this.orgMap = orgMap;
this.defaultOrg = defaultUri;
}
public URI apply(Object from) {
Map<URI, ? extends Org> uriToOrg = Maps.uniqueIndex(orgMap.get().values(), new Function<Org, URI>() {
@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);
}

View File

@ -24,44 +24,26 @@ import java.util.Map;
import javax.inject.Inject; import javax.inject.Inject;
import javax.inject.Singleton; import javax.inject.Singleton;
import org.jclouds.rest.ResourceNotFoundException;
import org.jclouds.vcloud.domain.Org; import org.jclouds.vcloud.domain.Org;
import org.jclouds.vcloud.terremark.domain.TerremarkOrg; import org.jclouds.vcloud.terremark.domain.TerremarkOrg;
import com.google.common.base.Function; import com.google.common.base.Function;
import com.google.common.base.Supplier; import com.google.common.base.Supplier;
import com.google.common.collect.Maps;
/** /**
* *
* @author Adrian Cole * @author Adrian Cole
*/ */
@Singleton @Singleton
public class OrgURIToKeysListEndpoint implements Function<Object, URI> { public class OrgURIToKeysListEndpoint extends OrgURIToEndpoint implements Function<Object, URI> {
private final Supplier<Map<String, ? extends Org>> orgMap;
private final URI defaultOrg;
@Inject @Inject
public OrgURIToKeysListEndpoint(Supplier<Map<String, ? extends Org>> orgMap, public OrgURIToKeysListEndpoint(Supplier<Map<String, ? extends Org>> orgMap,
@org.jclouds.vcloud.endpoints.Org URI defaultUri) { @org.jclouds.vcloud.endpoints.Org URI defaultUri) {
this.orgMap = orgMap; super(orgMap, defaultUri);
this.defaultOrg = defaultUri;
} }
public URI apply(Object from) { public URI getUriFromOrg(TerremarkOrg org) {
Map<URI, ? extends Org> uriToOrg = Maps.uniqueIndex(orgMap.get().values(), new Function<Org, URI>() { return org.getKeys().getHref();
@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);
}
} }
} }

View File

@ -0,0 +1,67 @@
/**
*
* Copyright (C) 2011 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.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<DataCenter> {
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);
}
}

View File

@ -0,0 +1,77 @@
/**
*
* Copyright (C) 2011 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.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<Set<DataCenter>> {
protected StringBuilder currentText = new StringBuilder();
protected Builder<DataCenter> dataCenters = ImmutableSet.<DataCenter> builder();
protected DataCenter.Builder builder = DataCenter.builder();
protected final DataCenterHandler handler;
public Set<DataCenter> getResult() {
try {
return dataCenters.build();
} finally {
dataCenters = ImmutableSet.<DataCenter> 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);
}
}

View File

@ -18,25 +18,22 @@
*/ */
package org.jclouds.vcloud.terremark.xml; 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 java.net.URI;
import javax.annotation.Resource;
import org.jclouds.http.functions.ParseSax.HandlerWithResult; 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.InternetService;
import org.jclouds.vcloud.terremark.domain.Protocol; import org.jclouds.vcloud.terremark.domain.Protocol;
import org.jclouds.vcloud.terremark.domain.PublicIpAddress; import org.jclouds.vcloud.terremark.domain.PublicIpAddress;
import org.xml.sax.Attributes; import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
/** /**
* @author Adrian Cole * @author Adrian Cole
*/ */
public class InternetServiceHandler extends HandlerWithResult<InternetService> { public class InternetServiceHandler extends HandlerWithResult<InternetService> {
@Resource
protected Logger logger = Logger.NULL;
private StringBuilder currentText = new StringBuilder(); private StringBuilder currentText = new StringBuilder();
private boolean inPublicIpAddress; private boolean inPublicIpAddress;
@ -51,10 +48,9 @@ public class InternetServiceHandler extends HandlerWithResult<InternetService> {
private boolean enabled; private boolean enabled;
private Protocol protocol; private Protocol protocol;
protected String currentOrNull() { protected int depth = 0;
String returnVal = currentText.toString().trim();
return returnVal.equals("") ? null : returnVal; private int thisDepth;
}
@Override @Override
public InternetService getResult() { public InternetService getResult() {
@ -62,40 +58,48 @@ public class InternetServiceHandler extends HandlerWithResult<InternetService> {
} }
@Override @Override
public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException { public void startElement(String uri, String localName, String qName, Attributes attrs) {
if (qName.equals("PublicIpAddress")) { depth++;
if (equalsOrSuffix(qName, "InternetService")) {
thisDepth = depth;
} else if (equalsOrSuffix(qName, "PublicIpAddress")) {
inPublicIpAddress = true; inPublicIpAddress = true;
} }
} }
public void endElement(String uri, String name, String qName) { public void endElement(String uri, String name, String qName) {
String current = currentOrNull(); depth--;
if (qName.equals("PublicIpAddress")) { if (equalsOrSuffix(qName, "PublicIpAddress")) {
inPublicIpAddress = false;
publicIpAddress = new PublicIpAddress(address, addressLocation); publicIpAddress = new PublicIpAddress(address, addressLocation);
address = null; address = null;
addressLocation = null; addressLocation = null;
inPublicIpAddress = false; } else {
} else if (current != null) { String value = currentOrNull(currentText);
if (qName.equals("Href")) { if (value != null && !value.equals("")) {
if (inPublicIpAddress) if (depth == thisDepth) {
addressLocation = URI.create(current); if (equalsOrSuffix(qName, "Href")) {
else location = URI.create(value);
location = URI.create(current); } else if (equalsOrSuffix(qName, "Name")) {
} else if (qName.equals("Name")) { serviceName = value;
if (inPublicIpAddress) } else if (equalsOrSuffix(qName, "Port")) {
address = current; port = Integer.parseInt(value);
else } else if (equalsOrSuffix(qName, "Protocol")) {
serviceName = current; protocol = Protocol.valueOf(value);
} else if (qName.equals("Port")) { } else if (equalsOrSuffix(qName, "Enabled")) {
port = Integer.parseInt(current); enabled = Boolean.parseBoolean(value);
} else if (qName.equals("Protocol")) { } else if (equalsOrSuffix(qName, "Timeout")) {
protocol = Protocol.valueOf(current); timeout = Integer.parseInt(value);
} else if (qName.equals("Enabled")) { } else if (equalsOrSuffix(qName, "Description")) {
enabled = Boolean.parseBoolean(current); description = currentOrNull(currentText);
} else if (qName.equals("Timeout")) { }
timeout = Integer.parseInt(current); } else if (inPublicIpAddress) {
} else if (qName.equals("Description")) { if (equalsOrSuffix(qName, "Href")) {
description = current; addressLocation = URI.create(value);
} else if (equalsOrSuffix(qName, "Name")) {
address = value;
}
}
} }
} }
currentText = new StringBuilder(); currentText = new StringBuilder();

View File

@ -18,28 +18,26 @@
*/ */
package org.jclouds.vcloud.terremark.xml; package org.jclouds.vcloud.terremark.xml;
import static org.jclouds.util.SaxUtils.equalsOrSuffix;
import java.util.Set; import java.util.Set;
import javax.annotation.Resource;
import javax.inject.Inject; import javax.inject.Inject;
import org.jclouds.http.functions.ParseSax.HandlerWithResult; 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.InternetService;
import org.xml.sax.Attributes; 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 * @author Adrian Cole
*/ */
public class InternetServicesHandler extends HandlerWithResult<Set<InternetService>> { public class InternetServicesHandler extends HandlerWithResult<Set<InternetService>> {
@Resource
protected Logger logger = Logger.NULL;
private final InternetServiceHandler handler; private final InternetServiceHandler handler;
Set<InternetService> result = Sets.newLinkedHashSet(); private Builder<InternetService> builder = ImmutableSet.<InternetService> builder();
@Inject @Inject
public InternetServicesHandler(InternetServiceHandler handler) { public InternetServicesHandler(InternetServiceHandler handler) {
@ -48,24 +46,44 @@ public class InternetServicesHandler extends HandlerWithResult<Set<InternetServi
@Override @Override
public Set<InternetService> getResult() { public Set<InternetService> getResult() {
return result; try {
return builder.build();
} finally {
builder = ImmutableSet.<InternetService> builder();
}
} }
int depth;
private boolean inInternetService;
@Override @Override
public void startElement(String uri, String localName, String qName, Attributes attributes) public void startElement(String uri, String localName, String qName, Attributes attrs) {
throws SAXException { depth++;
handler.startElement(uri, localName, qName, attributes); 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) { public void endElement(String uri, String name, String qName) {
handler.endElement(uri, name, qName); depth--;
if (qName.equals("InternetService")) { if (depth == 1) {
result.add(handler.getResult()); 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) { public void characters(char ch[], int start, int length) {
handler.characters(ch, start, length); if (inInternetService) {
handler.characters(ch, start, length);
}
} }
} }

View File

@ -18,13 +18,14 @@
*/ */
package org.jclouds.vcloud.terremark.xml; 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.newReferenceType;
import static org.jclouds.vcloud.util.Utils.putReferenceType;
import java.util.Map; import java.util.Map;
import javax.inject.Inject; import javax.inject.Inject;
import org.jclouds.util.SaxUtils;
import org.jclouds.vcloud.domain.ReferenceType; import org.jclouds.vcloud.domain.ReferenceType;
import org.jclouds.vcloud.terremark.domain.TerremarkOrg; import org.jclouds.vcloud.terremark.domain.TerremarkOrg;
import org.jclouds.vcloud.terremark.domain.internal.TerremarkOrgImpl; 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.Attributes;
import org.xml.sax.SAXException; import org.xml.sax.SAXException;
import com.google.common.collect.Maps;
/** /**
* @author Adrian Cole * @author Adrian Cole
*/ */
@ -42,24 +45,37 @@ public class TerremarkOrgHandler extends OrgHandler {
super(taskHandler); super(taskHandler);
} }
private ReferenceType keysList; protected ReferenceType keysList;
protected Map<String, ReferenceType> tasksLists = Maps.newLinkedHashMap();
public TerremarkOrg getResult() { public TerremarkOrg getResult() {
return new TerremarkOrgImpl(org.getName(), org.getType(), org.getHref(), description, catalogs, vdcs, networks, return new TerremarkOrgImpl(org.getName(), org.getType(), org.getHref(), description, catalogs, vdcs, networks,
tasksList, keysList); tasksLists, keysList);
} }
@Override @Override
public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException { public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException {
Map<String, String> attributes = cleanseAttributes(attrs); Map<String, String> attributes = SaxUtils.cleanseAttributes(attrs);
super.startElement(uri, localName, qName, attrs); if (qName.endsWith("Org")) {
if (qName.equals("Link")) { org = newReferenceType(attributes);
if (attributes.containsKey("type")) { } else if (qName.endsWith("Link")) {
String type = attributes.get("type"); String type = attributes.get("type");
if (type != null && type.endsWith("keysList+xml")) { if (type != null) {
keysList = newReferenceType(attributes); 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);
} }
} }
} }

View File

@ -20,16 +20,15 @@ package org.jclouds.vcloud.terremark.xml;
import java.net.URI; import java.net.URI;
import java.util.Arrays; import java.util.Arrays;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import javax.annotation.Resource; import javax.annotation.Resource;
import org.jclouds.http.functions.ParseSax.HandlerWithResult; import org.jclouds.http.functions.ParseSax.HandlerWithResult;
import org.jclouds.logging.Logger; 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.NetworkAdapter;
import org.jclouds.vcloud.terremark.domain.Subnet; import org.jclouds.vcloud.terremark.domain.Subnet;
import org.jclouds.vcloud.terremark.domain.VAppExtendedInfo;
import org.xml.sax.Attributes; import org.xml.sax.Attributes;
import org.xml.sax.SAXException; import org.xml.sax.SAXException;

View File

@ -0,0 +1,115 @@
/**
*
* Copyright (C) 2011 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.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 <T extends TerremarkVCloudClient>{
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<IPSocket> 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.<Module> of(new Log4JLoggingModule()), overrides).getComputeService();
socketTester = new RetryablePredicate<IPSocket>(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();
}
}

View File

@ -31,9 +31,9 @@ import static org.testng.Assert.assertNotNull;
import java.io.IOException; import java.io.IOException;
import java.net.URI; import java.net.URI;
import java.util.List; import java.util.List;
import java.util.Map.Entry;
import java.util.Properties; import java.util.Properties;
import java.util.Set; import java.util.Set;
import java.util.Map.Entry;
import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException; import java.util.concurrent.TimeoutException;
@ -48,8 +48,8 @@ import org.jclouds.predicates.RetryablePredicate;
import org.jclouds.predicates.SocketOpen; import org.jclouds.predicates.SocketOpen;
import org.jclouds.rest.RestContextFactory; import org.jclouds.rest.RestContextFactory;
import org.jclouds.ssh.SshClient; import org.jclouds.ssh.SshClient;
import org.jclouds.ssh.SshException;
import org.jclouds.ssh.SshClient.Factory; import org.jclouds.ssh.SshClient.Factory;
import org.jclouds.ssh.SshException;
import org.jclouds.ssh.jsch.config.JschSshClientModule; import org.jclouds.ssh.jsch.config.JschSshClientModule;
import org.jclouds.vcloud.VCloudExpressClientLiveTest; import org.jclouds.vcloud.VCloudExpressClientLiveTest;
import org.jclouds.vcloud.VCloudExpressMediaType; import org.jclouds.vcloud.VCloudExpressMediaType;
@ -99,7 +99,14 @@ public abstract class TerremarkClientLiveTest extends VCloudExpressClientLiveTes
protected VCloudExpressVApp clone; protected VCloudExpressVApp clone;
protected VDC vdc; protected VDC vdc;
public static final String PREFIX = System.getProperty("user.name") + "-terremark"; 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 @Test
public void testGetAllInternetServices() throws Exception { public void testGetAllInternetServices() throws Exception {
for (InternetService service : tmClient.getAllInternetServicesInVDC(tmClient.findVDCInOrgNamed(null, null) for (InternetService service : tmClient.getAllInternetServicesInVDC(tmClient.findVDCInOrgNamed(null, null)

View File

@ -0,0 +1,47 @@
/**
*
* Copyright (C) 2011 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.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());
}
}

View File

@ -0,0 +1,52 @@
/**
*
* Copyright (C) 2011 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.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<DataCenter> result = factory.create(injector.getInstance(DataCentersHandler.class)).parse(is);
ImmutableSet<DataCenter> expects = ImmutableSet.<DataCenter>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());
}
}

View File

@ -46,11 +46,11 @@ public class InternetServicesHandlerTest extends BaseHandlerTest {
InputStream is = getClass().getResourceAsStream("/terremark/InternetServices.xml"); InputStream is = getClass().getResourceAsStream("/terremark/InternetServices.xml");
Set<InternetService> result = factory.create(injector.getInstance(InternetServicesHandler.class)).parse(is); Set<InternetService> 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"), .create("https://services.vcloudexpress.terremark.com/api/v0.8/InternetServices/524"),
new PublicIpAddress("10.1.22.159", URI new PublicIpAddress("10.1.22.159", URI
.create("https://services.vcloudexpress.terremark.com/api/v0.8/PublicIps/4208")), 45, .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 { public void test2() throws UnknownHostException {

View File

@ -78,9 +78,11 @@ public class TerremarkOrgHandlerTest extends BaseHandlerTest {
assertEquals(result.getVDCs(), ImmutableMap.of("Miami Environment 1", new ReferenceTypeImpl( assertEquals(result.getVDCs(), ImmutableMap.of("Miami Environment 1", new ReferenceTypeImpl(
"Miami Environment 1", VCloudExpressMediaType.VDC_XML, URI "Miami Environment 1", VCloudExpressMediaType.VDC_XML, URI
.create("https://services.vcloudexpress.terremark.com/api/v0.8a-ext1.6/vdc/32")))); .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 assertEquals(result.getTasksLists(), ImmutableMap.of(
.create("https://services.vcloudexpress.terremark.com/api/v0.8a-ext1.6/vdc/32/tasksList"))); "Miami Environment 1 Tasks List",
assertEquals(result.getKeysList(), new ReferenceTypeImpl("Keys", "application/vnd.tmrk.vcloudExpress.keysList+xml", 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"))); URI.create("https://services.vcloudexpress.terremark.com/api/v0.8a-ext1.6/extensions/org/48/keys")));
} }

View File

@ -0,0 +1,9 @@
<DataCenter>
<Code>MIA</Code>
<Id>1</Id>
<Name>Terremark - Miami</Name>
</DataCenter>

View File

@ -0,0 +1,23 @@
<DataCenterList xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<DataCenter>
<Code>MIA</Code>
<Id>1</Id>
<Name>Terremark - Miami</Name>
</DataCenter>
<DataCenter>
<Code>CUA</Code>
<Id>3670</Id>
<Name>Terremark - Culpeper</Name>
</DataCenter>
</DataCenterList>

View File

@ -54,7 +54,6 @@ list, Alan Dipert and MeikelBrandmeyer."
(is (compute-service? (as-compute-service (compute-context *compute*))))) (is (compute-service? (as-compute-service (compute-context *compute*)))))
(deftest nodes-test (deftest nodes-test
(is (empty? (nodes)))
(is (create-node "fred" (build-template (is (create-node "fred" (build-template
*compute* {} ))) *compute* {} )))
(is (= 1 (count (nodes)))) (is (= 1 (count (nodes))))

View File

@ -159,7 +159,7 @@
<configuration> <configuration>
<instructions> <instructions>
<Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName> <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
<Export-Package>org.jclouds.vcloud.terremark.*;version="${project.version}"</Export-Package> <Export-Package>org.jclouds.vcloud.terremark.*;version="${project.version}",org.jclouds.terremark.ecloud.*;version="${project.version}"</Export-Package>
<Import-Package>org.jclouds.*;version="${project.version}",*</Import-Package> <Import-Package>org.jclouds.*;version="${project.version}",*</Import-Package>
</instructions> </instructions>
</configuration> </configuration>

View File

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

View File

@ -0,0 +1,67 @@
/**
*
* Copyright (C) 2011 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.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<String, ReferenceType> catalogs, Map<String, ReferenceType> vdcs, Map<String, ReferenceType> networks,
Map<String, ReferenceType> 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;
}
}

View File

@ -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 <a href=
* "http://support.theenterprisecloud.com/kb/default.asp?id=960&Lang=1&SID="
* />
* @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<? extends Set<KeyPair>> listDataCentersInOrg(
@Nullable @EndpointParam(parser = OrgURIToDataCentersListEndpoint.class) URI org);
/**
* @see DataCenterOperationsClient#listDataCenters
*/
@GET
@Consumes(DATACENTERSLIST_XML)
@XMLResponseParser(DataCentersHandler.class)
@ExceptionParser(ReturnEmptySetOnNotFoundOr404.class)
ListenableFuture<? extends Set<DataCenter>> listDataCenters(@EndpointParam URI dataCenters);
}

View File

@ -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
* <p/>
* 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<DataCenter> listDataCentersInOrg(URI orgId);
/**
* This call will get the list of data centers by list id.
*
* @return data centers
*/
Set<DataCenter> listDataCenters(URI dataCentersList);
}

View File

@ -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 <a href=
* "http://support.theenterprisecloud.com/kb/default.asp?id=954&Lang=1&SID="
* />
* @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<? extends Map<String, Integer>> getTagNameToUsageCountInOrg(
@Nullable @EndpointParam(parser = OrgURIToTagsListEndpoint.class) URI org);
/**
* @see TagOperationsClient#getTagNameToUsageCount
*/
@GET
@Consumes(TAGSLISTLIST_XML)
@XMLResponseParser(TagNameToUsageCountHandler.class)
@ExceptionParser(ReturnEmptyMapOnNotFoundOr404.class)
ListenableFuture<? extends Map<String, Integer>> getTagNameToUsageCount(@EndpointParam URI tagList);
}

View File

@ -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
* <p/>
*
* @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<String, Integer> getTagNameToUsageCountInOrg(URI orgId);
/**
* This call returns the list of all tags by list id.
*
* @return tags
*/
Map<String, Integer> getTagNameToUsageCount(URI tagsList);
}

View File

@ -0,0 +1,51 @@
/**
*
* Copyright (C) 2011 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.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<Object, URI> {
@Inject
public OrgURIToDataCentersListEndpoint(Supplier<Map<String, ? extends Org>> orgMap,
@org.jclouds.vcloud.endpoints.Org URI defaultUri) {
super(orgMap, defaultUri);
}
public URI getUriFromOrg(TerremarkOrg org) {
return TerremarkECloudOrg.class.cast(org).getDataCenters().getHref();
}
}

View File

@ -0,0 +1,51 @@
/**
*
* Copyright (C) 2011 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.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<Object, URI> {
@Inject
public OrgURIToTagsListEndpoint(Supplier<Map<String, ? extends Org>> orgMap,
@org.jclouds.vcloud.endpoints.Org URI defaultUri) {
super(orgMap, defaultUri);
}
public URI getUriFromOrg(TerremarkOrg org) {
return TerremarkECloudOrg.class.cast(org).getTags().getHref();
}
}

View File

@ -0,0 +1,61 @@
/**
*
* Copyright (C) 2011 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.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<Map<String, Integer>> {
protected StringBuilder currentText = new StringBuilder();
private Builder<String, Integer> builder = ImmutableMap.<String, Integer> builder();
private String name;
public Map<String, Integer> getResult() {
try {
return builder.build();
} finally {
builder = ImmutableMap.<String, Integer> 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);
}
}

View File

@ -0,0 +1,71 @@
/**
*
* Copyright (C) 2011 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.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<String, String> 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);
}
}
}
}
}

View File

@ -20,6 +20,7 @@ package org.jclouds.vcloud.terremark;
import static javax.ws.rs.core.MediaType.APPLICATION_XML; import static javax.ws.rs.core.MediaType.APPLICATION_XML;
import static org.jclouds.vcloud.VCloudMediaType.NETWORK_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.INTERNETSERVICESLIST_XML;
import static org.jclouds.vcloud.terremark.TerremarkECloudMediaType.INTERNETSERVICE_XML; import static org.jclouds.vcloud.terremark.TerremarkECloudMediaType.INTERNETSERVICE_XML;
import static org.jclouds.vcloud.terremark.TerremarkECloudMediaType.IPADDRESS_LIST_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.Path;
import javax.ws.rs.Produces; import javax.ws.rs.Produces;
import org.jclouds.rest.annotations.Delegate;
import org.jclouds.rest.annotations.EndpointParam; import org.jclouds.rest.annotations.EndpointParam;
import org.jclouds.rest.annotations.ExceptionParser; import org.jclouds.rest.annotations.ExceptionParser;
import org.jclouds.rest.annotations.MapBinder; 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.ReturnEmptySetOnNotFoundOr404;
import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404; import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404;
import org.jclouds.rest.functions.ReturnVoidOnNotFoundOr404; 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.filters.SetVCloudTokenCookie;
import org.jclouds.vcloud.functions.OrgNameToEndpoint;
import org.jclouds.vcloud.functions.OrgNameVDCNameResourceEntityNameToEndpoint; import org.jclouds.vcloud.functions.OrgNameVDCNameResourceEntityNameToEndpoint;
import org.jclouds.vcloud.terremark.binders.BindCreateKeyToXmlPayload; import org.jclouds.vcloud.terremark.binders.BindCreateKeyToXmlPayload;
import org.jclouds.vcloud.terremark.domain.InternetService; 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.Protocol;
import org.jclouds.vcloud.terremark.domain.PublicIpAddress; import org.jclouds.vcloud.terremark.domain.PublicIpAddress;
import org.jclouds.vcloud.terremark.domain.TerremarkNetwork; 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.TerremarkOrgNetwork;
import org.jclouds.vcloud.terremark.domain.VAppExtendedInfo;
import org.jclouds.vcloud.terremark.functions.OrgURIToKeysListEndpoint; import org.jclouds.vcloud.terremark.functions.OrgURIToKeysListEndpoint;
import org.jclouds.vcloud.terremark.functions.VDCURIToInternetServicesEndpoint; import org.jclouds.vcloud.terremark.functions.VDCURIToInternetServicesEndpoint;
import org.jclouds.vcloud.terremark.functions.VDCURIToPublicIPsEndpoint; import org.jclouds.vcloud.terremark.functions.VDCURIToPublicIPsEndpoint;
@ -84,7 +92,35 @@ import com.google.common.util.concurrent.ListenableFuture;
*/ */
@RequestFilters(SetVCloudTokenCookie.class) @RequestFilters(SetVCloudTokenCookie.class)
public interface TerremarkECloudAsyncClient extends TerremarkVCloudAsyncClient { 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<? extends TerremarkECloudOrg> getOrg(@EndpointParam URI orgId);
@Override
@GET
@XMLResponseParser(TerremarkECloudOrgHandler.class)
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
@Consumes(ORG_XML)
ListenableFuture<? extends TerremarkOrg> findOrgNamed(
@Nullable @EndpointParam(parser = OrgNameToEndpoint.class) String orgName);
/** /**
* @see TerremarkVCloudExpressClient#getAllInternetServices * @see TerremarkVCloudExpressClient#getAllInternetServices
*/ */
@ -152,7 +188,7 @@ public interface TerremarkECloudAsyncClient extends TerremarkVCloudAsyncClient {
@Nullable @EndpointParam(parser = OrgURIToKeysListEndpoint.class) URI org, String keyName); @Nullable @EndpointParam(parser = OrgURIToKeysListEndpoint.class) URI org, String keyName);
/** /**
* @see TerremarkVCloudExpressClient#listKeyPairsInOrgNamed * @see TerremarkVCloudExpressClient#listKeyPairsInOrg
*/ */
@GET @GET
@Consumes(KEYSLIST_XML) @Consumes(KEYSLIST_XML)
@ -262,4 +298,5 @@ public interface TerremarkECloudAsyncClient extends TerremarkVCloudAsyncClient {
@XMLResponseParser(VAppExtendedInfoHandler.class) @XMLResponseParser(VAppExtendedInfoHandler.class)
@ExceptionParser(ReturnNullOnNotFoundOr404.class) @ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<? extends VAppExtendedInfo> getVAppExtendedInfo(@EndpointParam URI href); ListenableFuture<? extends VAppExtendedInfo> getVAppExtendedInfo(@EndpointParam URI href);
} }

View File

@ -25,6 +25,10 @@ import java.util.concurrent.TimeUnit;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import org.jclouds.concurrent.Timeout; 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.IpAddress;
import org.jclouds.vcloud.terremark.domain.PublicIpAddress; import org.jclouds.vcloud.terremark.domain.PublicIpAddress;
import org.jclouds.vcloud.terremark.domain.TerremarkNetwork; 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. * Provides access to VCloud resources via their REST API.
* <p/> * <p/>
* *
* @see <a href= "http://support.theenterprisecloud.com/kb/default.asp?id=645&Lang=1&SID=" /> * @see <a href=
* "http://support.theenterprisecloud.com/kb/default.asp?id=645&Lang=1&SID="
* />
* @author Adrian Cole * @author Adrian Cole
*/ */
@Timeout(duration = 300, timeUnit = TimeUnit.SECONDS) @Timeout(duration = 300, timeUnit = TimeUnit.SECONDS)
public interface TerremarkECloudClient extends TerremarkVCloudClient { 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 * Allocate a new public IP
@ -56,14 +81,16 @@ public interface TerremarkECloudClient extends TerremarkVCloudClient {
TerremarkOrgNetwork getNetwork(URI network); TerremarkOrgNetwork getNetwork(URI network);
TerremarkNetwork getTerremarkNetwork(URI network); TerremarkNetwork getTerremarkNetwork(URI network);
Set<IpAddress> getIpAddresses(URI network); Set<IpAddress> getIpAddresses(URI network);
/** /**
* Returns extended information for the vApp. * Returns extended information for the vApp.
* *
* @param vApp The URI at which the vApp information is available. * @param vApp
* @return Extended vApp information like tags, long name, network adapter information. * The URI at which the vApp information is available.
* @return Extended vApp information like tags, long name, network adapter
* information.
*/ */
VAppExtendedInfo getVAppExtendedInfo(URI href); VAppExtendedInfo getVAppExtendedInfo(URI href);
} }

View File

@ -22,7 +22,7 @@ import javax.ws.rs.core.MediaType;
/** /**
* Resource Types used in Terremark eCloud * Resource Types used in Terremark eCloud
* *
* @see MediaType * @see MediaType
*/ */
public interface TerremarkECloudMediaType extends TerremarkVCloudMediaType { public interface TerremarkECloudMediaType extends TerremarkVCloudMediaType {
@ -66,6 +66,36 @@ public interface TerremarkECloudMediaType extends TerremarkVCloudMediaType {
* "application/vnd.tmrk.ecloud.keysList+xml" * "application/vnd.tmrk.ecloud.keysList+xml"
*/ */
public final static MediaType KEYSLIST_XML_TYPE = new MediaType("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" * "application/vnd.tmrk.ecloud.ipAddressList+xml"
@ -75,7 +105,8 @@ public interface TerremarkECloudMediaType extends TerremarkVCloudMediaType {
/** /**
* "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"); public final static MediaType IPADDRESSES_LIST_XML_TYPE = new MediaType("application",
"vnd.tmrk.ecloud.ipAddressList+xml");
/** /**
* "application/vnd.tmrk.ecloud.vApp+xml" * "application/vnd.tmrk.ecloud.vApp+xml"

View File

@ -29,7 +29,7 @@ import javax.inject.Inject;
import javax.inject.Singleton; import javax.inject.Singleton;
import org.jclouds.compute.domain.OperatingSystem; 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.domain.OsFamily;
import org.jclouds.compute.util.ComputeServiceUtils; import org.jclouds.compute.util.ComputeServiceUtils;
import org.jclouds.vcloud.compute.functions.ParseOsFromVAppTemplateName; import org.jclouds.vcloud.compute.functions.ParseOsFromVAppTemplateName;
@ -50,7 +50,7 @@ public class TerremarkECloudParseOsFromVAppTemplateName extends ParseOsFromVAppT
@Override @Override
public OperatingSystem apply(String from) { public OperatingSystem apply(String from) {
checkNotNull(from, "vapp template name"); checkNotNull(from, "vapp template name");
OperatingSystemBuilder builder = new OperatingSystemBuilder(); Builder builder = new OperatingSystem.Builder();
builder.description(from); builder.description(from);
if (from.equals("-Windows 2003 Std. R2 SQL 2005 Std. (x64)")) if (from.equals("-Windows 2003 Std. R2 SQL 2005 Std. (x64)"))
System.out.print(';'); System.out.print(';');

View File

@ -29,6 +29,10 @@ import javax.inject.Singleton;
import org.jclouds.http.RequiresHttp; import org.jclouds.http.RequiresHttp;
import org.jclouds.rest.ConfiguresRestClient; import org.jclouds.rest.ConfiguresRestClient;
import org.jclouds.rest.ResourceNotFoundException; 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.VCloudExpressAsyncClient;
import org.jclouds.vcloud.VCloudExpressClient; import org.jclouds.vcloud.VCloudExpressClient;
import org.jclouds.vcloud.domain.ReferenceType; 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 org.jclouds.vcloud.terremark.domain.TerremarkOrgNetwork;
import com.google.common.base.Predicate; import com.google.common.base.Predicate;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Iterables; import com.google.common.collect.Iterables;
import com.google.inject.Injector; import com.google.inject.Injector;
import com.google.inject.Provides; import com.google.inject.Provides;
@ -54,8 +59,13 @@ import com.google.inject.Provides;
public class TerremarkECloudRestClientModule extends public class TerremarkECloudRestClientModule extends
TerremarkRestClientModule<TerremarkECloudClient, TerremarkECloudAsyncClient> { TerremarkRestClientModule<TerremarkECloudClient, TerremarkECloudAsyncClient> {
public static final Map<Class<?>, Class<?>> DELEGATE_MAP = ImmutableMap.<Class<?>, Class<?>> builder()//
.put(DataCenterOperationsClient.class, DataCenterOperationsAsyncClient.class)//
.put(TagOperationsClient.class, TagOperationsAsyncClient.class)//
.build();
public TerremarkECloudRestClientModule() { public TerremarkECloudRestClientModule() {
super(TerremarkECloudClient.class, TerremarkECloudAsyncClient.class); super(TerremarkECloudClient.class, TerremarkECloudAsyncClient.class, DELEGATE_MAP);
} }
@Provides @Provides

View File

@ -0,0 +1,243 @@
/**
*
* Copyright (C) 2011 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.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<T> extends RestClientTest<T> {
@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<VCloudSession> sessionSupplier) {
super(sessionSupplier, null);
}
@Override
public Map<String, ReferenceType> get() {
return Maps.transformValues(sessionSupplier.get().getOrgs(), new Function<ReferenceType, ReferenceType>() {
@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<String, Org> get() {
return ImmutableMap.<String, Org> of(
"org",
new TerremarkECloudOrgImpl("org", null,
URI.create("https://vcloud.safesecureweb.com/api/v0.8/org/1"), null, ImmutableMap
.<String, ReferenceType> of(
"catalog",
new ReferenceTypeImpl("catalog", TerremarkECloudMediaType.CATALOG_XML, URI
.create("https://vcloud.safesecureweb.com/api/v0.8/catalog/1"))),
ImmutableMap.<String, ReferenceType> of(
"vdc",
new ReferenceTypeImpl("vdc", TerremarkECloudMediaType.VDC_XML, URI
.create("https://vcloud.safesecureweb.com/api/v0.8/vdc/1"))), ImmutableMap
.<String, ReferenceType> of(), ImmutableMap.<String, ReferenceType> 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<ReferenceType> orgs) {
return URI.create("https://org");
}
@Override
protected String provideOrgName(@org.jclouds.vcloud.endpoints.Org Iterable<ReferenceType> 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<ReferenceType> provideOrgs(Supplier<VCloudSession> 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<Map<String, String>> 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<String, Map<String, ? extends org.jclouds.vcloud.domain.VDC>> get() {
return ImmutableMap.<String, Map<String, ? extends org.jclouds.vcloud.domain.VDC>> of("org",
ImmutableMap.<String, org.jclouds.vcloud.domain.VDC> of(
"vdc",
new TerremarkVDCImpl("vdc", null, URI.create("https://vcloud.safesecureweb.com/api/v0.8/vdc/1"),
VDCStatus.READY, null, "description", ImmutableSet.<Task> 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.<String, ReferenceType> 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
.<String, ReferenceType> 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")))));
}
}
}

View File

@ -0,0 +1,31 @@
/**
*
* Copyright (C) 2011 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.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<TerremarkECloudClient> {
}

View File

@ -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<DataCenterOperationsAsyncClient> {
@Override
protected TypeLiteral<RestAnnotationProcessor<DataCenterOperationsAsyncClient>> createTypeLiteral() {
return new TypeLiteral<RestAnnotationProcessor<DataCenterOperationsAsyncClient>>() {
};
}
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);
}
}

View File

@ -0,0 +1,45 @@
/**
*
* Copyright (C) 2011 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.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()));
}
}
}

View File

@ -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<TagOperationsAsyncClient> {
@Override
protected TypeLiteral<RestAnnotationProcessor<TagOperationsAsyncClient>> createTypeLiteral() {
return new TypeLiteral<RestAnnotationProcessor<TagOperationsAsyncClient>>() {
};
}
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);
}
}

View File

@ -0,0 +1,45 @@
/**
*
* Copyright (C) 2011 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.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()));
}
}
}

View File

@ -0,0 +1,73 @@
package org.jclouds.terremark.ecloud.xml;
/**
*
* Copyright (C) 2011 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.
* ====================================================================
*/
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<String, Integer> result = factory.create(injector.getInstance(TagNameToUsageCountHandler.class)).parse(is);
assertEquals(result, ImmutableMap.<String, Integer> of("Tag1", 1, "Tag2", 5, "Tag3", 12));
}
}

View File

@ -0,0 +1,131 @@
package org.jclouds.terremark.ecloud.xml;
/**
*
* Copyright (C) 2011 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.
* ====================================================================
*/
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")));
}
}

View File

@ -18,56 +18,27 @@
*/ */
package org.jclouds.vcloud.terremark; 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.jclouds.vcloud.terremark.options.AddInternetServiceOptions.Builder.disabled;
import static org.testng.Assert.assertEquals;
import java.io.IOException; import java.io.IOException;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.net.URI; 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.HttpRequest;
import org.jclouds.http.RequiresHttp;
import org.jclouds.http.functions.ParseSax; import org.jclouds.http.functions.ParseSax;
import org.jclouds.http.functions.ReleasePayloadAndReturn; import org.jclouds.http.functions.ReleasePayloadAndReturn;
import org.jclouds.rest.ConfiguresRestClient;
import org.jclouds.rest.ResourceNotFoundException; 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.ReturnEmptySetOnNotFoundOr404;
import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404; import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404;
import org.jclouds.rest.functions.ReturnVoidOnNotFoundOr404; import org.jclouds.rest.functions.ReturnVoidOnNotFoundOr404;
import org.jclouds.rest.internal.RestAnnotationProcessor; import org.jclouds.rest.internal.RestAnnotationProcessor;
import org.jclouds.terremark.ecloud.BaseTerremarkECloudAsyncClientTest;
import org.jclouds.util.Strings2; 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.domain.network.NetworkConfig;
import org.jclouds.vcloud.filters.SetVCloudTokenCookie;
import org.jclouds.vcloud.functions.ParseTaskFromLocationHeader; import org.jclouds.vcloud.functions.ParseTaskFromLocationHeader;
import org.jclouds.vcloud.options.InstantiateVAppTemplateOptions; 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.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.AddInternetServiceOptions;
import org.jclouds.vcloud.terremark.options.AddNodeOptions; import org.jclouds.vcloud.terremark.options.AddNodeOptions;
import org.jclouds.vcloud.terremark.options.TerremarkInstantiateVAppTemplateOptions; 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.jclouds.vcloud.xml.VCloudExpressVAppHandler;
import org.testng.annotations.Test; 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; import com.google.inject.TypeLiteral;
/** /**
* Tests behavior of {@code TerremarkECloudAsyncClient} * Tests behavior of {@code TerremarkECloudAsyncClient}
* *
* @author Adrian Cole * @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", sequential = true, testName = "TerremarkECloudAsyncClientTest") @Test(groups = "unit", singleThreaded = true, testName = "TerremarkECloudAsyncClientTest")
public class TerremarkECloudAsyncClientTest extends RestClientTest<TerremarkECloudAsyncClient> { public class TerremarkECloudAsyncClientTest extends BaseTerremarkECloudAsyncClientTest<TerremarkECloudAsyncClient> {
@Override
protected TypeLiteral<RestAnnotationProcessor<TerremarkECloudAsyncClient>> createTypeLiteral() {
return new TypeLiteral<RestAnnotationProcessor<TerremarkECloudAsyncClient>>() {
};
}
public void testNetwork() throws SecurityException, NoSuchMethodException, IOException { public void testNetwork() throws SecurityException, NoSuchMethodException, IOException {
Method method = TerremarkECloudAsyncClient.class.getMethod("getNetwork", URI.class); Method method = TerremarkECloudAsyncClient.class.getMethod("getNetwork", URI.class);
HttpRequest request = processor.createRequest(method, HttpRequest request = processor.createRequest(method,
@ -559,173 +531,4 @@ public class TerremarkECloudAsyncClientTest extends RestClientTest<TerremarkEClo
checkFilters(request); checkFilters(request);
} }
@Override
protected void checkFilters(HttpRequest request) {
assertEquals(request.getFilters().size(), 1);
assertEquals(request.getFilters().get(0).getClass(), SetVCloudTokenCookie.class);
}
@Override
protected TypeLiteral<RestAnnotationProcessor<TerremarkECloudAsyncClient>> createTypeLiteral() {
return new TypeLiteral<RestAnnotationProcessor<TerremarkECloudAsyncClient>>() {
};
}
@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<VCloudSession> sessionSupplier) {
super(sessionSupplier, null);
}
@Override
public Map<String, ReferenceType> get() {
return Maps.transformValues(sessionSupplier.get().getOrgs(), new Function<ReferenceType, ReferenceType>() {
@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<String, Org> get() {
return ImmutableMap.<String, Org> of(
"org",
new TerremarkOrgImpl("org", null, URI.create("https://vcloud.safesecureweb.com/api/v0.8/org/1"),
null, ImmutableMap.<String, ReferenceType> of(
"catalog",
new ReferenceTypeImpl("catalog", TerremarkECloudMediaType.CATALOG_XML, URI
.create("https://vcloud.safesecureweb.com/api/v0.8/catalog/1"))), ImmutableMap
.<String, ReferenceType> of(
"vdc",
new ReferenceTypeImpl("vdc", TerremarkECloudMediaType.VDC_XML, URI
.create("https://vcloud.safesecureweb.com/api/v0.8/vdc/1"))), ImmutableMap
.<String, ReferenceType> 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<ReferenceType> orgs) {
return URI.create("https://org");
}
@Override
protected String provideOrgName(@org.jclouds.vcloud.endpoints.Org Iterable<ReferenceType> 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<ReferenceType> provideOrgs(Supplier<VCloudSession> 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<Map<String, String>> 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<String, Map<String, ? extends org.jclouds.vcloud.domain.VDC>> get() {
return ImmutableMap.<String, Map<String, ? extends org.jclouds.vcloud.domain.VDC>> of("org",
ImmutableMap.<String, org.jclouds.vcloud.domain.VDC> of(
"vdc",
new TerremarkVDCImpl("vdc", null, URI.create("https://vcloud.safesecureweb.com/api/v0.8/vdc/1"),
VDCStatus.READY, null, "description", ImmutableSet.<Task> 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.<String, ReferenceType> 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
.<String, ReferenceType> 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")))));
}
}
} }

View File

@ -24,7 +24,7 @@ import java.io.InputStream;
import java.util.Map; import java.util.Map;
import java.util.Set; 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.domain.OsFamily;
import org.jclouds.compute.reference.ComputeServiceConstants; import org.jclouds.compute.reference.ComputeServiceConstants;
import org.jclouds.http.functions.ParseSax; import org.jclouds.http.functions.ParseSax;
@ -66,100 +66,100 @@ public class TerremarkECloudParseOsFromVAppTemplateNameTest {
assertEquals(Sets.newLinkedHashSet(Iterables.transform(names, function)), ImmutableSet.of( assertEquals(Sets.newLinkedHashSet(Iterables.transform(names, function)), ImmutableSet.of(
// CentOS 5 (x64) // 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(), .is64Bit(true).build(),
// CentOS 5 (x86) // 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(), .is64Bit(false).build(),
// CentOS 5.5 x32 // 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(), .is64Bit(false).build(),
// CentOS 5.5 x64 // 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(), .is64Bit(true).build(),
// Red Hat Enterprise Linux 5 (x64) // 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 (x64)").is64Bit(true).build(),
// Red Hat Enterprise Linux 5 (x86) // 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 (x86)").is64Bit(false).build(),
// Red Hat Enterprise Linux 5.5 x32 // 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 x32").is64Bit(false).build(),
// Red Hat Enterprise Linux 5.5 x64 // 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(), "Red Hat Enterprise Linux 5.5 x64").is64Bit(true).build(),
// Sun Solaris 10 (x64) // 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(), .is64Bit(true).build(),
// Ubuntu 8.04 LTS (x64) // 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(), .description("Ubuntu 8.04 LTS (x64)").is64Bit(true).build(),
// Ubuntu 8.04 LTS (x86) // 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(), .description("Ubuntu 8.04 LTS (x86)").is64Bit(false).build(),
// Ubuntu Server 10.04 x32 // 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 x32").is64Bit(false).build(),
// Ubuntu Server 10.04 x64 // 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(), "Ubuntu Server 10.04 x64").is64Bit(true).build(),
// -Windows 2003 Std. R2 SQL 2005 Std. (x64) // -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 2005 Std. (x64)").is64Bit(true).build(),
// -Windows 2003 Std. R2 SQL 2008 Std. (x64) // -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 2003 Std. R2 SQL 2008 Std. (x64)").is64Bit(true).build(),
// -Windows 2008 R2 Std wSQL 2008 R2 Std (x64) // -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 Std (x64)").is64Bit(true).build(),
// -Windows 2008 R2 Std wSQL 2008 R2 Web (x64) // -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 R2 Std wSQL 2008 R2 Web (x64)").is64Bit(true).build(),
// -Windows 2008 Std wSQL 2008 Std (x64) // -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 Std (x64)").is64Bit(true).build(),
// -Windows 2008 Std wSQL 2008 Web (x64) // -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 2008 Std wSQL 2008 Web (x64)").is64Bit(true).build(),
// -Windows Server 2003 R2 Enterprise Edition (x64) // -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 (x64)").is64Bit(true).build(),
// -Windows Server 2003 R2 Enterprise Edition (x86) // -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 Enterprise Edition (x86)").is64Bit(false).build(),
// -Windows Server 2003 R2 Standard Edition (x64) // -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 (x64)").is64Bit(true).build(),
// -Windows Server 2003 R2 Standard Edition (x86) // -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 2003 R2 Standard Edition (x86)").is64Bit(false).build(),
// -Windows Server 2008 Enterprise Edition (x64) // -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 (x64)").is64Bit(true).build(),
// -Windows Server 2008 Enterprise Edition (x86) // -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 Enterprise Edition (x86)").is64Bit(false).build(),
// -Windows Server 2008 R2 Enterprise Edition (x64) // -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 Enterprise Edition (x64)").is64Bit(true).build(),
// -Windows Server 2008 R2 Standard Edition (x64) // -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 Standard Edition (x64)").is64Bit(true).build(),
// -Windows Server 2008 R2 Web Edition (x64) // -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 R2 Web Edition (x64)").is64Bit(true).build(),
// -Windows Server 2008 Standard Edition (x64) // -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 (x64)").is64Bit(true).build(),
// -Windows Server 2008 Standard Edition (x86) // -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 Standard Edition (x86)").is64Bit(false).build(),
// -Windows Server 2008 Web Edition (x64) // -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 (x64)").is64Bit(true).build(),
// -Windows Server 2008 Web Edition (x86) // -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() "-Windows Server 2008 Web Edition (x86)").is64Bit(false).build()
)); ));

View File

@ -0,0 +1,27 @@
<Tags xmlns="urn:tmrk:eCloudExtensions-2.8" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<Tag>
<Name>Tag1</Name>
<UsageCount>1</UsageCount>
</Tag>
<Tag>
<Name>Tag2</Name>
<UsageCount>5</UsageCount>
</Tag>
<Tag>
<Name>Tag3</Name>
<UsageCount>12</UsageCount>
</Tag>
</Tags>

View File

@ -0,0 +1,12 @@
<Org href="https://services.enterprisecloud.terremark.com/api/v0.8b-ext2.8/org/1910324" name="Cloud Conscious, LLC" xmlns="http://www.vmware.com/vcloud/v0.8" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Link rel="down" href="https://services.enterprisecloud.terremark.com/api/v0.8b-ext2.8/vdc/1155" type="application/vnd.vmware.vcloud.vdc+xml" name="Cloud Conscious LLC - MIA"/>
<Link rel="down" href="https://services.enterprisecloud.terremark.com/api/v0.8b-ext2.8/vdc/1169" type="application/vnd.vmware.vcloud.vdc+xml" name="Cloud Conscious LLC - AMA"/>
<Link rel="down" href="https://services.enterprisecloud.terremark.com/api/v0.8b-ext2.8/vdc/1169/catalog" type="application/vnd.vmware.vcloud.catalog+xml" name="Cloud Conscious LLC - AMA Catalog"/>
<Link rel="down" href="https://services.enterprisecloud.terremark.com/api/v0.8b-ext2.8/vdc/1155/catalog" type="application/vnd.vmware.vcloud.catalog+xml" name="Cloud Conscious LLC - MIA Catalog"/>
<Link rel="down" href="https://services.enterprisecloud.terremark.com/api/v0.8b-ext2.8/vdc/1169/tasksList" type="application/vnd.vmware.vcloud.tasksList+xml" name="Cloud Conscious LLC - AMA Tasks List"/>
<Link rel="down" href="https://services.enterprisecloud.terremark.com/api/v0.8b-ext2.8/vdc/1155/tasksList" type="application/vnd.vmware.vcloud.tasksList+xml" name="Cloud Conscious LLC - MIA Tasks List"/>
<Link rel="down" href="https://services.enterprisecloud.terremark.com/api/v0.8b-ext2.8/extensions/org/1910324/keys" type="application/vnd.tmrk.ecloud.keysList+xml" name="Keys"/>
<Link rel="down" href="https://services.enterprisecloud.terremark.com/api/v0.8b-ext2.8/extensions/org/1910324/deviceTags" type="application/vnd.tmrk.ecloud.tagsList+xml" name="Device Tags"/>
<Link rel="down" href="https://services.enterprisecloud.terremark.com/api/v0.8b-ext2.8/extensions/org/1910324/vappCatalog" type="application/vnd.tmrk.ecloud.VAppCatalogList+xml" name="VApp Catalog"/>
<Link rel="down" href="https://services.enterprisecloud.terremark.com/api/v0.8b-ext2.8/extensions/org/1910324/dataCenters" type="application/vnd.tmrk.ecloud.dataCentersList+xml" name="DataCenters"/>
</Org>

View File

@ -48,9 +48,9 @@ import org.jclouds.rest.functions.ReturnVoidOnNotFoundOr404;
import org.jclouds.rest.internal.RestAnnotationProcessor; import org.jclouds.rest.internal.RestAnnotationProcessor;
import org.jclouds.util.Strings2; import org.jclouds.util.Strings2;
import org.jclouds.vcloud.CommonVCloudClient; import org.jclouds.vcloud.CommonVCloudClient;
import org.jclouds.vcloud.VCloudVersionsAsyncClient;
import org.jclouds.vcloud.VCloudExpressAsyncClientTest.VCloudRestClientModuleExtension.TestOrgCatalogItemSupplier; import org.jclouds.vcloud.VCloudExpressAsyncClientTest.VCloudRestClientModuleExtension.TestOrgCatalogItemSupplier;
import org.jclouds.vcloud.VCloudExpressAsyncClientTest.VCloudRestClientModuleExtension.TestOrgCatalogSupplier; import org.jclouds.vcloud.VCloudExpressAsyncClientTest.VCloudRestClientModuleExtension.TestOrgCatalogSupplier;
import org.jclouds.vcloud.VCloudVersionsAsyncClient;
import org.jclouds.vcloud.domain.AllocationModel; import org.jclouds.vcloud.domain.AllocationModel;
import org.jclouds.vcloud.domain.Capacity; import org.jclouds.vcloud.domain.Capacity;
import org.jclouds.vcloud.domain.Catalog; import org.jclouds.vcloud.domain.Catalog;
@ -718,9 +718,10 @@ public class TerremarkVCloudExpressAsyncClientTest extends RestClientTest<Terrem
"vdc", "vdc",
new ReferenceTypeImpl("vdc", TerremarkVCloudExpressMediaType.VDC_XML, URI new ReferenceTypeImpl("vdc", TerremarkVCloudExpressMediaType.VDC_XML, URI
.create("https://vcloud.safesecureweb.com/api/v0.8/vdc/1"))), ImmutableMap .create("https://vcloud.safesecureweb.com/api/v0.8/vdc/1"))), ImmutableMap
.<String, ReferenceType> of(), new ReferenceTypeImpl("tasksList", .<String, ReferenceType> of(), ImmutableMap.<String, ReferenceType> of(
TerremarkVCloudExpressMediaType.TASKSLIST_XML, URI "tasksList",
.create("https://vcloud.safesecureweb.com/api/v0.8/tasksList/1")), new ReferenceTypeImpl("tasksList", TerremarkVCloudExpressMediaType.TASKSLIST_XML, URI
.create("https://vcloud.safesecureweb.com/api/v0.8/tasksList/1"))),
new ReferenceTypeImpl("keysList", TerremarkVCloudExpressMediaType.KEYSLIST_XML, URI new ReferenceTypeImpl("keysList", TerremarkVCloudExpressMediaType.KEYSLIST_XML, URI
.create("https://vcloud.safesecureweb.com/api/v0.8/keysList/1")))); .create("https://vcloud.safesecureweb.com/api/v0.8/keysList/1"))));
} }