merged changes from upstream

This commit is contained in:
David Ribeiro Alves 2012-03-04 18:08:19 +00:00
commit af662850a9
343 changed files with 22172 additions and 3476 deletions

1
.gitignore vendored
View File

@ -13,3 +13,4 @@ bin/
*.iws
*.DS_STORE
TAGS
.metadata/

View File

@ -30,6 +30,11 @@
<artifactId>jclouds-allloadbalancer</artifactId>
<name>allloadbalancer</name>
<dependencies>
<dependency>
<groupId>org.jclouds.provider</groupId>
<artifactId>cloudloadbalancers-uk</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.jclouds.provider</groupId>
<artifactId>cloudloadbalancers-us</artifactId>

View File

@ -72,7 +72,7 @@
<dependency>
<groupId>org.yaml</groupId>
<artifactId>snakeyaml</artifactId>
<version>1.8</version>
<version>1.10</version>
</dependency>
</dependencies>

View File

@ -62,6 +62,7 @@ import com.google.common.cache.LoadingCache;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import com.google.common.collect.ImmutableSet.Builder;
import com.google.common.util.concurrent.UncheckedExecutionException;
@ -186,21 +187,28 @@ public class RunningInstanceToNodeMetadata implements Function<RunningInstance,
@VisibleForTesting
String getGroupForInstance(final RunningInstance instance) {
String group = parseGroupFrom(instance, instance.getGroupIds());
if(group == null && instance.getKeyName() != null) {
// when not using a generated security group, e.g. in VPC, try from key:
group = parseGroupFrom(instance, Sets.newHashSet(instance.getKeyName()));
}
return group;
}
private String parseGroupFrom(final RunningInstance instance, final Set<String> data) {
String group = null;
try {
group = Iterables.getOnlyElement(Iterables.filter(instance.getGroupIds(), new Predicate<String>() {
group = Iterables.getOnlyElement(Iterables.filter(data, new Predicate<String>() {
@Override
public boolean apply(String input) {
return input.startsWith("jclouds#") && input.endsWith("#" + instance.getRegion());
return input.startsWith("jclouds#") && input.contains("#" + instance.getRegion());
}
})).substring(8).replaceAll("#" + instance.getRegion() + "$", "");
})).split("#")[1];
} catch (NoSuchElementException e) {
logger.debug("no group parsed from %s's security groups: %s", instance.getId(), instance.getGroupIds());
logger.debug("no group parsed from %s's data: %s", instance.getId(), data);
} catch (IllegalArgumentException e) {
logger.debug("too many groups match %s; %s's security groups: %s", "jclouds#", instance.getId(), instance
.getGroupIds());
logger.debug("too many groups match %s; %s's data: %s", "jclouds#", instance.getId(), data);
}
return group;
}

View File

@ -217,6 +217,20 @@ public class RunningInstanceToNodeMetadataTest {
.hardware(m1_small32().build()).location(provider).build());
}
@Test
public void testGroupNameIsSetWhenCustomKeyNameIsSetAndSecurityGroupIsGenerated() {
checkGroupName(RunningInstance.builder().instanceId("id").imageId("image").instanceType("m1.small")
.instanceState(InstanceState.RUNNING).region("us-east-1").keyName("custom-key")
.groupId("jclouds#groupname#us-east-1").build());
}
@Test
public void testGroupNameIsSetWhenCustomSecurityGroupIsSetAndKeyNameIsGenerated() {
checkGroupName(RunningInstance.builder().instanceId("id").imageId("image").instanceType("m1.small")
.instanceState(InstanceState.RUNNING).region("us-east-1").groupId("custom-sec")
.keyName("jclouds#groupname#us-east-1#23").build());
}
protected RunningInstance firstInstanceFromResource(String resource) {
RunningInstance server = Iterables.get(Iterables.get(DescribeInstancesResponseHandlerTest
.parseRunningInstances(resource), 0), 0);
@ -239,6 +253,12 @@ public class RunningInstanceToNodeMetadataTest {
return createNodeParser(hardware, locations, credentialStore, instanceToNodeState, instanceToImage);
}
private void checkGroupName(RunningInstance instance) {
assertEquals("groupname", createNodeParser(ImmutableSet.<Hardware> of(), ImmutableSet
.<Location> of(), ImmutableSet.<Image> of(), ImmutableMap.<String, Credentials> of())
.apply(instance).getGroup());
}
private RunningInstanceToNodeMetadata createNodeParser(final ImmutableSet<Hardware> hardware,
final ImmutableSet<Location> locations, Map<String, Credentials> credentialStore,
Map<InstanceState, NodeState> instanceToNodeState, LoadingCache<RegionAndName, Image> instanceToImage) {

View File

@ -46,7 +46,7 @@
<dependency>
<groupId>com.jamesmurty.utils</groupId>
<artifactId>java-xmlbuilder</artifactId>
<version>0.3</version>
<version>0.4</version>
</dependency>
<dependency>
<groupId>org.jclouds.common</groupId>

View File

@ -48,7 +48,7 @@
<dependency>
<groupId>com.jamesmurty.utils</groupId>
<artifactId>java-xmlbuilder</artifactId>
<version>0.3</version>
<version>0.4</version>
</dependency>
<dependency>
<groupId>org.jclouds</groupId>

View File

@ -52,6 +52,7 @@ import org.jclouds.vcloud.options.InstantiateVAppTemplateOptions;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Function;
import com.google.common.base.Supplier;
import com.google.common.cache.LoadingCache;
import com.google.common.collect.ImmutableSet;
import com.jamesmurty.utils.XMLBuilder;
@ -67,7 +68,7 @@ public class BindInstantiateVAppTemplateParamsToXmlPayload implements MapBinder
protected final String ns;
protected final String schema;
protected final BindToStringPayload stringBinder;
protected final ReferenceType defaultNetwork;
protected final Supplier<ReferenceType> defaultNetwork;
protected final FenceMode defaultFenceMode;
protected final LoadingCache<URI, VAppTemplate> templateCache;
protected final Function<VAppTemplate, String> defaultNetworkNameInTemplate;
@ -76,7 +77,7 @@ public class BindInstantiateVAppTemplateParamsToXmlPayload implements MapBinder
public BindInstantiateVAppTemplateParamsToXmlPayload(LoadingCache<URI, VAppTemplate> templateCache,
@Network Function<VAppTemplate, String> defaultNetworkNameInTemplate, BindToStringPayload stringBinder,
@Named(PROPERTY_VCLOUD_XML_NAMESPACE) String ns, @Named(PROPERTY_VCLOUD_XML_SCHEMA) String schema,
@Network ReferenceType network, FenceMode fenceMode) {
@Network Supplier<ReferenceType> network, FenceMode fenceMode) {
this.templateCache = templateCache;
this.defaultNetworkNameInTemplate = defaultNetworkNameInTemplate;
this.ns = ns;
@ -98,7 +99,7 @@ public class BindInstantiateVAppTemplateParamsToXmlPayload implements MapBinder
Set<NetworkConfig> networkConfig = null;
NetworkConfigDecorator networkConfigDecorator = new NetworkConfigDecorator(templateCache.getUnchecked(template),
defaultNetwork.getHref(), defaultFenceMode, defaultNetworkNameInTemplate);
defaultNetwork.get().getHref(), defaultFenceMode, defaultNetworkNameInTemplate);
InstantiateVAppTemplateOptions options = findOptionsInArgsOrNull(gRequest);

View File

@ -51,6 +51,8 @@ import org.jclouds.vcloud.functions.VAppTemplatesInOrg;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Function;
import com.google.common.base.Supplier;
import com.google.common.base.Suppliers;
import com.google.common.collect.ImmutableMap;
import com.google.inject.AbstractModule;
import com.google.inject.Provides;
@ -108,8 +110,16 @@ public class VCloudComputeServiceDependenciesModule extends AbstractModule {
@Provides
@Singleton
public NetworkConfig networkConfig(@Network ReferenceType network, FenceMode defaultFenceMode) {
return new NetworkConfig(network.getName(), network.getHref(), defaultFenceMode);
public Supplier<NetworkConfig> networkConfig(@Network Supplier<ReferenceType> network,
final FenceMode defaultFenceMode) {
return Suppliers.compose(new Function<ReferenceType, NetworkConfig>() {
@Override
public NetworkConfig apply(ReferenceType input) {
return new NetworkConfig(input.getName(), input.getHref(), defaultFenceMode);
}
}, network);
}
}

View File

@ -57,6 +57,7 @@ import org.jclouds.vcloud.domain.network.NetworkConfig;
import org.jclouds.vcloud.options.InstantiateVAppTemplateOptions;
import com.google.common.base.Predicate;
import com.google.common.base.Supplier;
import com.google.common.cache.LoadingCache;
import com.google.common.collect.ImmutableSet;
@ -72,13 +73,13 @@ public class InstantiateVAppTemplateWithGroupEncodedIntoNameThenCustomizeDeployA
protected final VCloudClient client;
protected final Predicate<URI> successTester;
protected final LoadingCache<URI, VAppTemplate> vAppTemplates;
protected final NetworkConfig defaultNetworkConfig;
protected final Supplier<NetworkConfig> defaultNetworkConfig;
protected final String buildVersion;
@Inject
protected InstantiateVAppTemplateWithGroupEncodedIntoNameThenCustomizeDeployAndPowerOn(VCloudClient client,
Predicate<URI> successTester, LoadingCache<URI, VAppTemplate> vAppTemplates,
NetworkConfig defaultNetworkConfig, @Named(PROPERTY_BUILD_VERSION) String buildVersion) {
Supplier<NetworkConfig> defaultNetworkConfig, @Named(PROPERTY_BUILD_VERSION) String buildVersion) {
this.client = client;
this.successTester = successTester;
this.vAppTemplates = vAppTemplates;
@ -142,9 +143,9 @@ public class InstantiateVAppTemplateWithGroupEncodedIntoNameThenCustomizeDeployA
// if we only have a disconnected network, let's add a new section for the upstream
// TODO: remove the disconnected entry
if (networkWithNoIpAllocation.apply(networkToConnect))
config = defaultNetworkConfig;
config = defaultNetworkConfig.get();
else
config = defaultNetworkConfig.toBuilder().networkName(networkToConnect.getName()).build();
config = defaultNetworkConfig.get().toBuilder().networkName(networkToConnect.getName()).build();
// note that in VCD 1.5, the network name after instantiation will be the same as the parent
InstantiateVAppTemplateOptions options = addNetworkConfig(config);

View File

@ -34,13 +34,14 @@ import org.jclouds.vcloud.suppliers.OnlyReferenceTypeFirstWithNameMatchingConfig
import com.google.common.base.Function;
import com.google.common.base.Predicate;
import com.google.common.base.Supplier;
import com.google.common.base.Suppliers;
/**
*
* @author Adrian Cole
*/
@Singleton
public class DefaultOrgForUser implements Function<String, ReferenceType> {
public class DefaultOrgForUser implements Function<String, Supplier<ReferenceType>> {
private final OnlyReferenceTypeFirstWithNameMatchingConfigurationKeyOrDefault selector;
private final Supplier<VCloudSession> sessionSupplier;
@ -55,10 +56,16 @@ public class DefaultOrgForUser implements Function<String, ReferenceType> {
}
@Override
public ReferenceType apply(String user) {
VCloudSession session = sessionSupplier.get();
checkState(session != null, "could not retrieve Session at %s", user);
return selector.apply(session.getOrgs().values());
public Supplier<ReferenceType> apply(final String user) {
return Suppliers.compose(new Function<VCloudSession, ReferenceType>() {
@Override
public ReferenceType apply(VCloudSession session) {
checkState(session != null, "could not retrieve Session at %s", user);
return selector.apply(session.getOrgs().values());
}
}, sessionSupplier);
}
}

View File

@ -57,7 +57,7 @@ public class DefaultVCloudReferencesModule extends AbstractModule {
@Provides
@org.jclouds.vcloud.endpoints.Org
@Singleton
protected ReferenceType provideDefaultOrg(DefaultOrgForUser defaultOrgURIForUser,
protected Supplier<ReferenceType> provideDefaultOrg(DefaultOrgForUser defaultOrgURIForUser,
@Named(PROPERTY_IDENTITY) String user) {
return defaultOrgURIForUser.apply(user);
}
@ -72,17 +72,17 @@ public class DefaultVCloudReferencesModule extends AbstractModule {
@Provides
@org.jclouds.vcloud.endpoints.TasksList
@Singleton
protected ReferenceType provideDefaultTasksList(DefaultTasksListForOrg defaultTasksListURIForOrg,
@org.jclouds.vcloud.endpoints.Org ReferenceType defaultOrg) {
return defaultTasksListURIForOrg.apply(defaultOrg);
protected Supplier<ReferenceType> provideDefaultTasksList(DefaultTasksListForOrg defaultTasksListURIForOrg,
@org.jclouds.vcloud.endpoints.Org Supplier<ReferenceType> defaultOrg) {
return Suppliers.compose(defaultTasksListURIForOrg, defaultOrg);
}
@Provides
@org.jclouds.vcloud.endpoints.Catalog
@Singleton
protected ReferenceType provideDefaultCatalog(DefaultCatalogForOrg defaultCatalogURIForOrg,
@org.jclouds.vcloud.endpoints.Org ReferenceType defaultOrg) {
return defaultCatalogURIForOrg.apply(defaultOrg);
protected Supplier<ReferenceType> provideDefaultCatalog(DefaultCatalogForOrg defaultCatalogURIForOrg,
@org.jclouds.vcloud.endpoints.Org Supplier<ReferenceType> defaultOrg) {
return Suppliers.compose(defaultCatalogURIForOrg, defaultOrg);
}
@Provides
@ -146,9 +146,9 @@ public class DefaultVCloudReferencesModule extends AbstractModule {
@Provides
@org.jclouds.vcloud.endpoints.VDC
@Singleton
protected ReferenceType provideDefaultVDC(DefaultVDCForOrg defaultVDCURIForOrg,
@org.jclouds.vcloud.endpoints.Org ReferenceType defaultOrg) {
return defaultVDCURIForOrg.apply(defaultOrg);
protected Supplier<ReferenceType> provideDefaultVDC(DefaultVDCForOrg defaultVDCURIForOrg,
@org.jclouds.vcloud.endpoints.Org Supplier<ReferenceType> defaultOrg) {
return Suppliers.compose(defaultVDCURIForOrg, defaultOrg);
}
@Provides
@ -161,9 +161,9 @@ public class DefaultVCloudReferencesModule extends AbstractModule {
@Provides
@org.jclouds.vcloud.endpoints.Network
@Singleton
protected ReferenceType provideDefaultNetwork(DefaultNetworkForVDC defaultNetworkURIForVDC,
@org.jclouds.vcloud.endpoints.VDC ReferenceType defaultVDC) {
return defaultNetworkURIForVDC.apply(defaultVDC);
protected Supplier<ReferenceType> provideDefaultNetwork(DefaultNetworkForVDC defaultNetworkURIForVDC,
@org.jclouds.vcloud.endpoints.VDC Supplier<ReferenceType> defaultVDC) {
return Suppliers.compose(defaultNetworkURIForVDC, defaultVDC);
}
@Provides

View File

@ -316,8 +316,15 @@ public class VCloudRestClientModule extends RestClientModule<VCloudClient, VClou
@VCloudToken
@Provides
String provideVCloudToken(Supplier<VCloudSession> cache) {
return checkNotNull(cache.get().getVCloudToken(), "No token present in session");
@Singleton
Supplier<String> provideVCloudToken(Supplier<VCloudSession> cache) {
return Suppliers.compose(new Function<VCloudSession, String>() {
@Override
public String apply(VCloudSession input) {
return checkNotNull(input.getVCloudToken(), "No token present in session");
}
}, cache);
}
@Provides
@ -419,9 +426,16 @@ public class VCloudRestClientModule extends RestClientModule<VCloudClient, VClou
@Provides
@Singleton
protected Org provideOrg(Supplier<Map<String, Org>> orgSupplier,
@org.jclouds.vcloud.endpoints.Org ReferenceType defaultOrg) {
return orgSupplier.get().get(defaultOrg.getName());
protected Supplier<Org> provideOrg(final Supplier<Map<String, Org>> orgSupplier,
@org.jclouds.vcloud.endpoints.Org Supplier<ReferenceType> defaultOrg) {
return Suppliers.compose(new Function<ReferenceType, Org>() {
@Override
public Org apply(ReferenceType input) {
return orgSupplier.get().get(input.getName());
}
}, defaultOrg);
}
@Provides

View File

@ -19,7 +19,6 @@
package org.jclouds.vcloud.filters;
import javax.inject.Inject;
import javax.inject.Provider;
import javax.inject.Singleton;
import javax.ws.rs.core.HttpHeaders;
@ -29,6 +28,8 @@ import org.jclouds.http.HttpRequestFilter;
import org.jclouds.http.utils.ModifyRequest;
import org.jclouds.vcloud.VCloudToken;
import com.google.common.base.Supplier;
/**
* Adds the VCloud Token to the request as a cookie
*
@ -37,10 +38,10 @@ import org.jclouds.vcloud.VCloudToken;
*/
@Singleton
public class SetVCloudTokenCookie implements HttpRequestFilter {
private Provider<String> vcloudTokenProvider;
private Supplier<String> vcloudTokenProvider;
@Inject
public SetVCloudTokenCookie(@VCloudToken Provider<String> authTokenProvider) {
public SetVCloudTokenCookie(@VCloudToken Supplier<String> authTokenProvider) {
this.vcloudTokenProvider = authTokenProvider;
}

View File

@ -42,12 +42,13 @@ import com.google.common.collect.Iterables;
@Singleton
public class OrgNameAndCatalogNameToEndpoint implements Function<Object, URI> {
private final Supplier<Map<String, Org>> orgMap;
private final ReferenceType defaultOrg;
private final ReferenceType defaultCatalog;
private final Supplier<ReferenceType> defaultOrg;
private final Supplier<ReferenceType> defaultCatalog;
@Inject
public OrgNameAndCatalogNameToEndpoint(Supplier<Map<String, Org>> orgMap,
@org.jclouds.vcloud.endpoints.Org ReferenceType defaultOrg, @Catalog ReferenceType defaultCatalog) {
@org.jclouds.vcloud.endpoints.Org Supplier<ReferenceType> defaultOrg,
@Catalog Supplier<ReferenceType> defaultCatalog) {
this.orgMap = orgMap;
this.defaultOrg = defaultOrg;
this.defaultCatalog = defaultCatalog;
@ -59,9 +60,9 @@ public class OrgNameAndCatalogNameToEndpoint implements Function<Object, URI> {
Object org = Iterables.get(orgCatalog, 0);
Object catalog = Iterables.get(orgCatalog, 1);
if (org == null && catalog == null)
return defaultCatalog.getHref();
return defaultCatalog.get().getHref();
else if (org == null)
org = defaultOrg.getName();
org = defaultOrg.get().getName();
try {
Map<String, ReferenceType> catalogs = checkNotNull(orgMap.get().get(org)).getCatalogs();

View File

@ -42,12 +42,12 @@ import com.google.common.collect.Iterables;
@Singleton
public class OrgNameAndVDCNameToEndpoint implements Function<Object, URI> {
private final Supplier<Map<String, Org>> orgNameToVDCEndpoint;
private final ReferenceType defaultOrg;
private final ReferenceType defaultVDC;
private final Supplier<ReferenceType> defaultOrg;
private final Supplier<ReferenceType> defaultVDC;
@Inject
public OrgNameAndVDCNameToEndpoint(Supplier<Map<String, Org>> orgNameToVDCEndpoint,
@org.jclouds.vcloud.endpoints.Org ReferenceType defaultOrg, @VDC ReferenceType defaultVDC) {
@org.jclouds.vcloud.endpoints.Org Supplier<ReferenceType> defaultOrg, @VDC Supplier<ReferenceType> defaultVDC) {
this.orgNameToVDCEndpoint = orgNameToVDCEndpoint;
this.defaultOrg = defaultOrg;
this.defaultVDC = defaultVDC;
@ -59,9 +59,9 @@ public class OrgNameAndVDCNameToEndpoint implements Function<Object, URI> {
Object org = Iterables.get(orgVdc, 0);
Object vdc = Iterables.get(orgVdc, 1);
if (org == null && vdc == null)
return defaultVDC.getHref();
return defaultVDC.get().getHref();
else if (org == null)
org = defaultOrg.getName();
org = defaultOrg.get().getName();
try {
Map<String, ReferenceType> vdcs = checkNotNull(orgNameToVDCEndpoint.get().get(org)).getVDCs();

View File

@ -42,13 +42,13 @@ import com.google.common.collect.Iterables;
@Singleton
public class OrgNameCatalogNameItemNameToEndpoint implements Function<Object, URI> {
private final Supplier<Map<String, Map<String, org.jclouds.vcloud.domain.Catalog>>> orgCatalogMap;
private final ReferenceType defaultOrg;
private final ReferenceType defaultCatalog;
private final Supplier<ReferenceType> defaultOrg;
private final Supplier<ReferenceType> defaultCatalog;
@Inject
public OrgNameCatalogNameItemNameToEndpoint(
Supplier<Map<String, Map<String, org.jclouds.vcloud.domain.Catalog>>> orgCatalogMap,
@Org ReferenceType defaultOrg, @Catalog ReferenceType defaultCatalog) {
@Org Supplier<ReferenceType> defaultOrg, @Catalog Supplier<ReferenceType> defaultCatalog) {
this.orgCatalogMap = orgCatalogMap;
this.defaultOrg = defaultOrg;
this.defaultCatalog = defaultCatalog;
@ -61,9 +61,9 @@ public class OrgNameCatalogNameItemNameToEndpoint implements Function<Object, UR
Object catalog = Iterables.get(orgCatalog, 1);
Object catalogItem = Iterables.get(orgCatalog, 2);
if (org == null)
org = defaultOrg.getName();
org = defaultOrg.get().getName();
if (catalog == null)
catalog = defaultCatalog.getName();
catalog = defaultCatalog.get().getName();
try {
Map<String, org.jclouds.vcloud.domain.Catalog> catalogs = checkNotNull(orgCatalogMap.get().get(org));
return catalogs.get(catalog).get(catalogItem).getHref();

View File

@ -43,13 +43,13 @@ import com.google.common.collect.Iterables;
@Singleton
public class OrgNameCatalogNameVAppTemplateNameToEndpoint implements Function<Object, URI> {
private final Supplier<Map<String, Map<String, Map<String, CatalogItem>>>> orgCatalogItemMap;
private final ReferenceType defaultOrg;
private final ReferenceType defaultCatalog;
private final Supplier<ReferenceType> defaultOrg;
private final Supplier<ReferenceType> defaultCatalog;
@Inject
public OrgNameCatalogNameVAppTemplateNameToEndpoint(
Supplier<Map<String, Map<String, Map<String, CatalogItem>>>> orgCatalogItemMap,
@Org ReferenceType defaultOrg, @Catalog ReferenceType defaultCatalog) {
@Org Supplier<ReferenceType> defaultOrg, @Catalog Supplier<ReferenceType> defaultCatalog) {
this.orgCatalogItemMap = orgCatalogItemMap;
this.defaultOrg = defaultOrg;
this.defaultCatalog = defaultCatalog;
@ -62,9 +62,9 @@ public class OrgNameCatalogNameVAppTemplateNameToEndpoint implements Function<Ob
Object catalog = Iterables.get(orgCatalog, 1);
Object catalogItem = Iterables.get(orgCatalog, 2);
if (org == null)
org = defaultOrg.getName();
org = defaultOrg.get().getName();
if (catalog == null)
catalog = defaultCatalog.getName();
catalog = defaultCatalog.get().getName();
Map<String, Map<String, Map<String, CatalogItem>>> orgCatalogItemMap = this.orgCatalogItemMap.get();
if (!orgCatalogItemMap.containsKey(org))

View File

@ -38,11 +38,11 @@ import com.google.common.base.Supplier;
@Singleton
public class OrgNameToEndpoint implements Function<Object, URI> {
private final Supplier<Map<String, ReferenceType>> orgNameToEndpointSupplier;
private final ReferenceType defaultOrg;
private final Supplier<ReferenceType> defaultOrg;
@Inject
public OrgNameToEndpoint(@Org Supplier<Map<String, ReferenceType>> orgNameToEndpointSupplier,
@Org ReferenceType defaultOrg) {
@Org Supplier<ReferenceType> defaultOrg) {
this.orgNameToEndpointSupplier = orgNameToEndpointSupplier;
this.defaultOrg = defaultOrg;
}
@ -50,7 +50,7 @@ public class OrgNameToEndpoint implements Function<Object, URI> {
public URI apply(Object from) {
try {
Map<String, ReferenceType> orgNameToEndpoint = orgNameToEndpointSupplier.get();
return from == null ? defaultOrg.getHref() : orgNameToEndpoint.get(from).getHref();
return from == null ? defaultOrg.get().getHref() : orgNameToEndpoint.get(from).getHref();
} catch (NullPointerException e) {
throw new NoSuchElementException("org " + from + " not found in " + orgNameToEndpointSupplier.get().keySet());
}

View File

@ -41,11 +41,11 @@ import com.google.common.base.Supplier;
@Singleton
public class OrgNameToTasksListEndpoint implements Function<Object, URI> {
private final Supplier<Map<String, Org>> orgMap;
private final ReferenceType defaultTasksList;
private final Supplier<ReferenceType> defaultTasksList;
@Inject
public OrgNameToTasksListEndpoint(Supplier<Map<String, Org>> orgMap,
@TasksList ReferenceType defaultTasksList) {
@TasksList Supplier<ReferenceType> defaultTasksList) {
this.orgMap = orgMap;
this.defaultTasksList = defaultTasksList;
}
@ -53,7 +53,7 @@ public class OrgNameToTasksListEndpoint implements Function<Object, URI> {
public URI apply(Object from) {
Object org = from;
if (org == null)
return defaultTasksList.getHref();
return defaultTasksList.get().getHref();
try {
return checkNotNull(orgMap.get().get(org)).getTasksList().getHref();
} catch (NullPointerException e) {

View File

@ -40,7 +40,7 @@ public class OrgNameVDCNameNetworkNameToEndpoint extends OrgNameVDCNameResourceN
@Inject
public OrgNameVDCNameNetworkNameToEndpoint(
Supplier<Map<String, Map<String, org.jclouds.vcloud.domain.VDC>>> orgVDCMap,
@Org ReferenceType defaultOrg, @VDC ReferenceType defaultVDC) {
@Org Supplier<ReferenceType> defaultOrg, @VDC Supplier<ReferenceType> defaultVDC) {
super(orgVDCMap, defaultOrg, defaultVDC);
}

View File

@ -40,7 +40,7 @@ public class OrgNameVDCNameResourceEntityNameToEndpoint extends OrgNameVDCNameRe
@Inject
public OrgNameVDCNameResourceEntityNameToEndpoint(
Supplier<Map<String, Map<String, org.jclouds.vcloud.domain.VDC>>> orgVDCMap,
@Org ReferenceType defaultOrg, @VDC ReferenceType defaultVDC) {
@Org Supplier<ReferenceType> defaultOrg, @VDC Supplier<ReferenceType> defaultVDC) {
super(orgVDCMap, defaultOrg, defaultVDC);
}

View File

@ -41,13 +41,13 @@ import com.google.common.collect.Iterables;
public abstract class OrgNameVDCNameResourceNameToEndpoint implements Function<Object, URI>{
protected final Supplier<Map<String, Map<String, org.jclouds.vcloud.domain.VDC>>> orgVDCMap;
protected final ReferenceType defaultOrg;
protected final ReferenceType defaultVDC;
protected final Supplier<ReferenceType> defaultOrg;
protected final Supplier<ReferenceType> defaultVDC;
@Inject
public OrgNameVDCNameResourceNameToEndpoint(
Supplier<Map<String, Map<String, org.jclouds.vcloud.domain.VDC>>> orgVDCMap,
@Org ReferenceType defaultOrg, @org.jclouds.vcloud.endpoints.VDC ReferenceType defaultVDC) {
@Org Supplier<ReferenceType> defaultOrg, @org.jclouds.vcloud.endpoints.VDC Supplier<ReferenceType> defaultVDC) {
this.orgVDCMap = orgVDCMap;
this.defaultOrg = defaultOrg;
this.defaultVDC = defaultVDC;
@ -60,9 +60,9 @@ public abstract class OrgNameVDCNameResourceNameToEndpoint implements Function<
Object vDC = Iterables.get(orgVDC, 1);
Object resource = Iterables.get(orgVDC, 2);
if (org == null)
org = defaultOrg.getName();
org = defaultOrg.get().getName();
if (vDC == null)
vDC = defaultVDC.getName();
vDC = defaultVDC.get().getName();
Map<String, Map<String, org.jclouds.vcloud.domain.VDC>> orgToVDCs = orgVDCMap.get();
checkState(orgToVDCs != null, "could not get map of org name to vdcs!");
Map<String, org.jclouds.vcloud.domain.VDC> vDCs = orgToVDCs.get(org);

View File

@ -55,15 +55,16 @@ public class DefaultVDC implements ImplicitLocationSupplier {
@Singleton
public static class IsDefaultVDC implements Predicate<Location> {
private final ReferenceType defaultVDC;
private final Supplier<ReferenceType> defaultVDCSupplier;
@Inject
IsDefaultVDC(@VDC ReferenceType defaultVDC) {
this.defaultVDC = checkNotNull(defaultVDC, "defaultVDC");
IsDefaultVDC(@VDC Supplier<ReferenceType> defaultVDCSupplier) {
this.defaultVDCSupplier = checkNotNull(defaultVDCSupplier, "defaultVDCSupplier");
}
@Override
public boolean apply(Location input) {
ReferenceType defaultVDC = defaultVDCSupplier.get();
return input.getScope() == LocationScope.ZONE && input.getId().equals(defaultVDC.getHref().toASCIIString());
}

View File

@ -49,6 +49,8 @@ import org.testng.annotations.Test;
import com.google.common.base.Function;
import com.google.common.base.Functions;
import com.google.common.base.Supplier;
import com.google.common.base.Suppliers;
import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache;
@ -102,9 +104,9 @@ public class BindInstantiateVAppTemplateParamsToXmlPayloadTest {
@Network
@Provides
@Singleton
ReferenceType provideNetwork() {
return new ReferenceTypeImpl(null, null, URI
.create("https://vcenterprise.bluelock.com/api/v1.0/network/1990"));
Supplier<ReferenceType> provideNetwork() {
return Suppliers.<ReferenceType>ofInstance(new ReferenceTypeImpl(null, null, URI
.create("https://vcenterprise.bluelock.com/api/v1.0/network/1990")));
}
}));
}

View File

@ -22,7 +22,6 @@ import static org.testng.Assert.assertEquals;
import java.net.URI;
import javax.inject.Provider;
import javax.ws.rs.core.HttpHeaders;
import org.jclouds.http.HttpRequest;
@ -30,6 +29,8 @@ import org.jclouds.vcloud.filters.SetVCloudTokenCookie;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;
import com.google.common.base.Supplier;
/**
* @author Adrian Cole
*/
@ -40,7 +41,7 @@ public class SetVCloudTokenCookieTest {
@BeforeTest
void setUp() {
filter = new SetVCloudTokenCookie(new Provider<String>() {
filter = new SetVCloudTokenCookie(new Supplier<String>() {
public String get() {
return "token";
}

View File

@ -139,9 +139,9 @@ public abstract class BaseVCloudAsyncClientTest<T> extends RestClientTest<T> {
}
@Override
protected Org provideOrg(Supplier<Map<String, Org>> orgSupplier,
@org.jclouds.vcloud.endpoints.Org ReferenceType defaultOrg) {
return ORG;
protected Supplier<Org> provideOrg(Supplier<Map<String, Org>> orgSupplier,
@org.jclouds.vcloud.endpoints.Org Supplier<ReferenceType> defaultOrg) {
return Suppliers.ofInstance(ORG);
}
@Override
@ -150,14 +150,18 @@ public abstract class BaseVCloudAsyncClientTest<T> extends RestClientTest<T> {
@Override
protected void configure() {
bind(ReferenceType.class).annotatedWith(org.jclouds.vcloud.endpoints.Org.class).toInstance(ORG_REF);
bind(ReferenceType.class).annotatedWith(org.jclouds.vcloud.endpoints.Catalog.class).toInstance(
CATALOG_REF);
bind(ReferenceType.class).annotatedWith(org.jclouds.vcloud.endpoints.TasksList.class).toInstance(
TASKSLIST_REF);
bind(ReferenceType.class).annotatedWith(org.jclouds.vcloud.endpoints.VDC.class).toInstance(VDC_REF);
bind(ReferenceType.class).annotatedWith(org.jclouds.vcloud.endpoints.Network.class).toInstance(
NETWORK_REF);
TypeLiteral<Supplier<ReferenceType>> refTypeSupplier = new TypeLiteral<Supplier<ReferenceType>>() {
};
bind(refTypeSupplier).annotatedWith(org.jclouds.vcloud.endpoints.Org.class).toInstance(
Suppliers.<ReferenceType> ofInstance(ORG_REF));
bind(refTypeSupplier).annotatedWith(org.jclouds.vcloud.endpoints.Catalog.class).toInstance(
Suppliers.<ReferenceType> ofInstance(CATALOG_REF));
bind(refTypeSupplier).annotatedWith(org.jclouds.vcloud.endpoints.TasksList.class).toInstance(
Suppliers.<ReferenceType> ofInstance(TASKSLIST_REF));
bind(refTypeSupplier).annotatedWith(org.jclouds.vcloud.endpoints.VDC.class).toInstance(
Suppliers.<ReferenceType> ofInstance(VDC_REF));
bind(refTypeSupplier).annotatedWith(org.jclouds.vcloud.endpoints.Network.class).toInstance(
Suppliers.<ReferenceType> ofInstance(NETWORK_REF));
}
});

View File

@ -43,7 +43,7 @@
<dependency>
<groupId>com.jamesmurty.utils</groupId>
<artifactId>java-xmlbuilder</artifactId>
<version>0.3</version>
<version>0.4</version>
</dependency>
<dependency>
<groupId>org.jclouds</groupId>

View File

@ -48,6 +48,7 @@ import org.jclouds.trmk.vcloud_0_8.endpoints.Network;
import org.jclouds.trmk.vcloud_0_8.options.InstantiateVAppTemplateOptions;
import org.jclouds.trmk.vcloud_0_8.options.InstantiateVAppTemplateOptions.NetworkConfig;
import com.google.common.base.Supplier;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Iterables;
import com.google.common.collect.Maps;
@ -67,13 +68,13 @@ public class BindInstantiateVAppTemplateParamsToXmlPayload implements MapBinder
private final BindToStringPayload stringBinder;
protected final Map<ResourceType, String> virtualHardwareToInstanceId = ImmutableMap.of(ResourceType.PROCESSOR, "1",
ResourceType.MEMORY, "2", ResourceType.DISK_DRIVE, "9");
private final ReferenceType defaultNetwork;
private final Supplier<ReferenceType> defaultNetwork;
private final String defaultFenceMode;
@Inject
public BindInstantiateVAppTemplateParamsToXmlPayload(BindToStringPayload stringBinder,
@Named(PROPERTY_VCLOUD_XML_NAMESPACE) String ns, @Named(PROPERTY_VCLOUD_XML_SCHEMA) String schema,
@Network ReferenceType network, @Named(PROPERTY_VCLOUD_DEFAULT_FENCEMODE) String fenceMode) {
@Network Supplier<ReferenceType> network, @Named(PROPERTY_VCLOUD_DEFAULT_FENCEMODE) String fenceMode) {
this.ns = ns;
this.schema = schema;
this.stringBinder = stringBinder;
@ -93,7 +94,7 @@ public class BindInstantiateVAppTemplateParamsToXmlPayload implements MapBinder
SortedMap<ResourceType, String> virtualHardwareQuantity = Maps.newTreeMap();
InstantiateVAppTemplateOptions options = findOptionsInArgsOrNull(gRequest);
String network = (defaultNetwork != null) ? defaultNetwork.getHref().toASCIIString() : null;
String network = (defaultNetwork != null) ? defaultNetwork.get().getHref().toASCIIString() : null;
String fenceMode = defaultFenceMode;
String networkName = name;
if (options != null) {

View File

@ -34,13 +34,14 @@ import org.jclouds.trmk.vcloud_0_8.suppliers.OnlyReferenceTypeFirstWithNameMatch
import com.google.common.base.Function;
import com.google.common.base.Predicate;
import com.google.common.base.Supplier;
import com.google.common.base.Suppliers;
/**
*
* @author Adrian Cole
*/
@Singleton
public class DefaultOrgForUser implements Function<String, ReferenceType> {
public class DefaultOrgForUser implements Function<String, Supplier<ReferenceType>> {
private final OnlyReferenceTypeFirstWithNameMatchingConfigurationKeyOrDefault selector;
private final Supplier<VCloudSession> sessionSupplier;
@ -55,10 +56,16 @@ public class DefaultOrgForUser implements Function<String, ReferenceType> {
}
@Override
public ReferenceType apply(String user) {
VCloudSession session = sessionSupplier.get();
checkState(session != null, "could not retrieve Session at %s", user);
return selector.apply(session.getOrgs().values());
public Supplier<ReferenceType> apply(final String user) {
return Suppliers.compose(new Function<VCloudSession, ReferenceType>() {
@Override
public ReferenceType apply(VCloudSession session) {
checkState(session != null, "could not retrieve Session at %s", user);
return selector.apply(session.getOrgs().values());
}
}, sessionSupplier);
}
}

View File

@ -54,7 +54,7 @@ public class DefaultVCloudReferencesModule extends AbstractModule {
@Provides
@org.jclouds.trmk.vcloud_0_8.endpoints.Org
@Singleton
protected ReferenceType provideDefaultOrg(DefaultOrgForUser defaultOrgURIForUser,
protected Supplier<ReferenceType> provideDefaultOrg(DefaultOrgForUser defaultOrgURIForUser,
@Named(PROPERTY_IDENTITY) String user) {
return defaultOrgURIForUser.apply(user);
}
@ -69,9 +69,9 @@ public class DefaultVCloudReferencesModule extends AbstractModule {
@Provides
@org.jclouds.trmk.vcloud_0_8.endpoints.TasksList
@Singleton
protected ReferenceType provideDefaultTasksList(DefaultTasksListForOrg defaultTasksListURIForOrg,
@org.jclouds.trmk.vcloud_0_8.endpoints.Org ReferenceType defaultOrg) {
return defaultTasksListURIForOrg.apply(defaultOrg);
protected Supplier<ReferenceType> provideDefaultTasksList(DefaultTasksListForOrg defaultTasksListURIForOrg,
@org.jclouds.trmk.vcloud_0_8.endpoints.Org Supplier<ReferenceType> defaultOrg) {
return Suppliers.compose(defaultTasksListURIForOrg, defaultOrg);
}
@Provides
@ -84,9 +84,9 @@ public class DefaultVCloudReferencesModule extends AbstractModule {
@Provides
@org.jclouds.trmk.vcloud_0_8.endpoints.Catalog
@Singleton
protected ReferenceType provideDefaultCatalog(DefaultCatalogForOrg defaultCatalogURIForOrg,
@org.jclouds.trmk.vcloud_0_8.endpoints.Org ReferenceType defaultOrg) {
return defaultCatalogURIForOrg.apply(defaultOrg);
protected Supplier<ReferenceType> provideDefaultCatalog(DefaultCatalogForOrg defaultCatalogURIForOrg,
@org.jclouds.trmk.vcloud_0_8.endpoints.Org Supplier<ReferenceType> defaultOrg) {
return Suppliers.compose(defaultCatalogURIForOrg, defaultOrg);
}
@Provides
@ -121,9 +121,9 @@ public class DefaultVCloudReferencesModule extends AbstractModule {
@Provides
@org.jclouds.trmk.vcloud_0_8.endpoints.VDC
@Singleton
protected ReferenceType provideDefaultVDC(DefaultVDCForOrg defaultVDCURIForOrg,
@org.jclouds.trmk.vcloud_0_8.endpoints.Org ReferenceType defaultOrg) {
return defaultVDCURIForOrg.apply(defaultOrg);
protected Supplier<ReferenceType> provideDefaultVDC(DefaultVDCForOrg defaultVDCURIForOrg,
@org.jclouds.trmk.vcloud_0_8.endpoints.Org Supplier<ReferenceType> defaultOrg) {
return Suppliers.compose(defaultVDCURIForOrg, defaultOrg);
}
@Provides
@ -136,9 +136,9 @@ public class DefaultVCloudReferencesModule extends AbstractModule {
@Provides
@org.jclouds.trmk.vcloud_0_8.endpoints.Network
@Singleton
protected ReferenceType provideDefaultNetwork(DefaultNetworkForVDC defaultNetworkURIForVDC,
@org.jclouds.trmk.vcloud_0_8.endpoints.VDC ReferenceType defaultVDC) {
return defaultNetworkURIForVDC.apply(defaultVDC);
protected Supplier<ReferenceType> provideDefaultNetwork(DefaultNetworkForVDC defaultNetworkURIForVDC,
@org.jclouds.trmk.vcloud_0_8.endpoints.VDC Supplier<ReferenceType> defaultVDC) {
return Suppliers.compose(defaultNetworkURIForVDC, defaultVDC);
}
@Provides

View File

@ -352,10 +352,17 @@ public class TerremarkVCloudRestClientModule<S extends TerremarkVCloudClient, A
@Provides
@Singleton
protected org.jclouds.trmk.vcloud_0_8.domain.Org provideOrg(
Supplier<Map<String, ? extends org.jclouds.trmk.vcloud_0_8.domain.Org>> orgSupplier,
@org.jclouds.trmk.vcloud_0_8.endpoints.Org ReferenceType defaultOrg) {
return orgSupplier.get().get(defaultOrg.getName());
protected Supplier<org.jclouds.trmk.vcloud_0_8.domain.Org> provideOrg(
final Supplier<Map<String, ? extends org.jclouds.trmk.vcloud_0_8.domain.Org>> orgSupplier,
@org.jclouds.trmk.vcloud_0_8.endpoints.Org Supplier<ReferenceType> defaultOrg) {
return Suppliers.compose(new Function<ReferenceType, org.jclouds.trmk.vcloud_0_8.domain.Org>() {
@Override
public org.jclouds.trmk.vcloud_0_8.domain.Org apply(ReferenceType input) {
return orgSupplier.get().get(input.getName());
}
}, defaultOrg);
}
@Provides

View File

@ -42,12 +42,12 @@ import com.google.common.collect.Iterables;
@Singleton
public class OrgNameAndCatalogNameToEndpoint implements Function<Object, URI> {
private final Supplier<Map<String, ? extends Org>> orgMap;
private final ReferenceType defaultOrg;
private final ReferenceType defaultCatalog;
private final Supplier<ReferenceType> defaultOrg;
private final Supplier<ReferenceType> defaultCatalog;
@Inject
public OrgNameAndCatalogNameToEndpoint(Supplier<Map<String, ? extends Org>> orgMap,
@org.jclouds.trmk.vcloud_0_8.endpoints.Org ReferenceType defaultOrg, @Catalog ReferenceType defaultCatalog) {
@org.jclouds.trmk.vcloud_0_8.endpoints.Org Supplier<ReferenceType> defaultOrg, @Catalog Supplier<ReferenceType> defaultCatalog) {
this.orgMap = orgMap;
this.defaultOrg = defaultOrg;
this.defaultCatalog = defaultCatalog;
@ -59,9 +59,9 @@ public class OrgNameAndCatalogNameToEndpoint implements Function<Object, URI> {
Object org = Iterables.get(orgCatalog, 0);
Object catalog = Iterables.get(orgCatalog, 1);
if (org == null && catalog == null)
return defaultCatalog.getHref();
return defaultCatalog.get().getHref();
else if (org == null)
org = defaultOrg.getName();
org = defaultOrg.get().getName();
try {
Map<String, ReferenceType> catalogs = checkNotNull(orgMap.get().get(org)).getCatalogs();

View File

@ -42,12 +42,12 @@ import com.google.common.collect.Iterables;
@Singleton
public class OrgNameAndTasksListNameToEndpoint implements Function<Object, URI> {
private final Supplier<Map<String, ? extends Org>> orgMap;
private final ReferenceType defaultOrg;
private final ReferenceType defaultTasksList;
private final Supplier<ReferenceType> defaultOrg;
private final Supplier<ReferenceType> defaultTasksList;
@Inject
public OrgNameAndTasksListNameToEndpoint(Supplier<Map<String, ? extends Org>> orgMap,
@org.jclouds.trmk.vcloud_0_8.endpoints.Org ReferenceType defaultOrg, @TasksList ReferenceType defaultTasksList) {
@org.jclouds.trmk.vcloud_0_8.endpoints.Org Supplier<ReferenceType> defaultOrg, @TasksList Supplier<ReferenceType> defaultTasksList) {
this.orgMap = orgMap;
this.defaultOrg = defaultOrg;
this.defaultTasksList = defaultTasksList;
@ -59,9 +59,9 @@ public class OrgNameAndTasksListNameToEndpoint implements Function<Object, URI>
Object org = Iterables.get(orgTasksList, 0);
Object tasksList = Iterables.get(orgTasksList, 1);
if (org == null && tasksList == null)
return defaultTasksList.getHref();
return defaultTasksList.get().getHref();
else if (org == null)
org = defaultOrg.getName();
org = defaultOrg.get().getName();
try {
Map<String, ReferenceType> tasksLists = checkNotNull(orgMap.get().get(org)).getTasksLists();

View File

@ -42,12 +42,12 @@ import com.google.common.collect.Iterables;
@Singleton
public class OrgNameAndVDCNameToEndpoint implements Function<Object, URI> {
private final Supplier<Map<String, ? extends Org>> orgNameToVDCEndpoint;
private final ReferenceType defaultOrg;
private final ReferenceType defaultVDC;
private final Supplier<ReferenceType> defaultOrg;
private final Supplier<ReferenceType> defaultVDC;
@Inject
public OrgNameAndVDCNameToEndpoint(Supplier<Map<String, ? extends Org>> orgNameToVDCEndpoint,
@org.jclouds.trmk.vcloud_0_8.endpoints.Org ReferenceType defaultOrg, @VDC ReferenceType defaultVDC) {
@org.jclouds.trmk.vcloud_0_8.endpoints.Org Supplier<ReferenceType> defaultOrg, @VDC Supplier<ReferenceType> defaultVDC) {
this.orgNameToVDCEndpoint = orgNameToVDCEndpoint;
this.defaultOrg = defaultOrg;
this.defaultVDC = defaultVDC;
@ -59,9 +59,9 @@ public class OrgNameAndVDCNameToEndpoint implements Function<Object, URI> {
Object org = Iterables.get(orgVdc, 0);
Object vdc = Iterables.get(orgVdc, 1);
if (org == null && vdc == null)
return defaultVDC.getHref();
return defaultVDC.get().getHref();
else if (org == null)
org = defaultOrg.getName();
org = defaultOrg.get().getName();
try {
Map<String, ReferenceType> vdcs = checkNotNull(orgNameToVDCEndpoint.get().get(org)).getVDCs();

View File

@ -42,13 +42,13 @@ import com.google.common.collect.Iterables;
@Singleton
public class OrgNameCatalogNameItemNameToEndpoint implements Function<Object, URI> {
private final Supplier<Map<String, Map<String, ? extends org.jclouds.trmk.vcloud_0_8.domain.Catalog>>> orgCatalogMap;
private final ReferenceType defaultOrg;
private final ReferenceType defaultCatalog;
private final Supplier<ReferenceType> defaultOrg;
private final Supplier<ReferenceType> defaultCatalog;
@Inject
public OrgNameCatalogNameItemNameToEndpoint(
Supplier<Map<String, Map<String, ? extends org.jclouds.trmk.vcloud_0_8.domain.Catalog>>> orgCatalogMap,
@Org ReferenceType defaultOrg, @Catalog ReferenceType defaultCatalog) {
@Org Supplier<ReferenceType> defaultOrg, @Catalog Supplier<ReferenceType> defaultCatalog) {
this.orgCatalogMap = orgCatalogMap;
this.defaultOrg = defaultOrg;
this.defaultCatalog = defaultCatalog;
@ -61,9 +61,9 @@ public class OrgNameCatalogNameItemNameToEndpoint implements Function<Object, UR
Object catalog = Iterables.get(orgCatalog, 1);
Object catalogItem = Iterables.get(orgCatalog, 2);
if (org == null)
org = defaultOrg.getName();
org = defaultOrg.get().getName();
if (catalog == null)
catalog = defaultCatalog.getName();
catalog = defaultCatalog.get().getName();
try {
Map<String, ? extends org.jclouds.trmk.vcloud_0_8.domain.Catalog> catalogs = checkNotNull(orgCatalogMap.get().get(org));
return catalogs.get(catalog).get(catalogItem).getHref();

View File

@ -43,13 +43,13 @@ import com.google.common.collect.Iterables;
@Singleton
public class OrgNameCatalogNameVAppTemplateNameToEndpoint implements Function<Object, URI> {
private final Supplier<Map<String, Map<String, Map<String, ? extends org.jclouds.trmk.vcloud_0_8.domain.CatalogItem>>>> orgCatalogItemMap;
private final ReferenceType defaultOrg;
private final ReferenceType defaultCatalog;
private final Supplier<ReferenceType> defaultOrg;
private final Supplier<ReferenceType> defaultCatalog;
@Inject
public OrgNameCatalogNameVAppTemplateNameToEndpoint(
Supplier<Map<String, Map<String, Map<String, ? extends org.jclouds.trmk.vcloud_0_8.domain.CatalogItem>>>> orgCatalogItemMap,
@Org ReferenceType defaultOrg, @Catalog ReferenceType defaultCatalog) {
@Org Supplier<ReferenceType> defaultOrg, @Catalog Supplier<ReferenceType> defaultCatalog) {
this.orgCatalogItemMap = orgCatalogItemMap;
this.defaultOrg = defaultOrg;
this.defaultCatalog = defaultCatalog;
@ -62,9 +62,9 @@ public class OrgNameCatalogNameVAppTemplateNameToEndpoint implements Function<Ob
Object catalog = Iterables.get(orgCatalog, 1);
Object catalogItem = Iterables.get(orgCatalog, 2);
if (org == null)
org = defaultOrg.getName();
org = defaultOrg.get().getName();
if (catalog == null)
catalog = defaultCatalog.getName();
catalog = defaultCatalog.get().getName();
Map<String, Map<String, Map<String, ? extends CatalogItem>>> orgCatalogItemMap = this.orgCatalogItemMap.get();
if (!orgCatalogItemMap.containsKey(org))

View File

@ -38,11 +38,11 @@ import com.google.common.base.Supplier;
@Singleton
public class OrgNameToEndpoint implements Function<Object, URI> {
private final Supplier<Map<String, ReferenceType>> orgNameToEndpointSupplier;
private final ReferenceType defaultOrg;
private final Supplier<ReferenceType> defaultOrg;
@Inject
public OrgNameToEndpoint(@Org Supplier<Map<String, ReferenceType>> orgNameToEndpointSupplier,
@Org ReferenceType defaultOrg) {
@Org Supplier<ReferenceType> defaultOrg) {
this.orgNameToEndpointSupplier = orgNameToEndpointSupplier;
this.defaultOrg = defaultOrg;
}
@ -50,7 +50,7 @@ public class OrgNameToEndpoint implements Function<Object, URI> {
public URI apply(Object from) {
try {
Map<String, ReferenceType> orgNameToEndpoint = orgNameToEndpointSupplier.get();
return from == null ? defaultOrg.getHref() : orgNameToEndpoint.get(from).getHref();
return from == null ? defaultOrg.get().getHref() : orgNameToEndpoint.get(from).getHref();
} catch (NullPointerException e) {
throw new NoSuchElementException("org " + from + " not found in " + orgNameToEndpointSupplier.get().keySet());
}

View File

@ -40,7 +40,7 @@ public class OrgNameVDCNameNetworkNameToEndpoint extends OrgNameVDCNameResourceN
@Inject
public OrgNameVDCNameNetworkNameToEndpoint(
Supplier<Map<String, Map<String, ? extends org.jclouds.trmk.vcloud_0_8.domain.VDC>>> orgVDCMap,
@Org ReferenceType defaultOrg, @VDC ReferenceType defaultVDC) {
@Org Supplier<ReferenceType> defaultOrg, @VDC Supplier<ReferenceType> defaultVDC) {
super(orgVDCMap, defaultOrg, defaultVDC);
}

View File

@ -40,7 +40,7 @@ public class OrgNameVDCNameResourceEntityNameToEndpoint extends OrgNameVDCNameRe
@Inject
public OrgNameVDCNameResourceEntityNameToEndpoint(
Supplier<Map<String, Map<String, ? extends org.jclouds.trmk.vcloud_0_8.domain.VDC>>> orgVDCMap,
@Org ReferenceType defaultOrg, @VDC ReferenceType defaultVDC) {
@Org Supplier<ReferenceType> defaultOrg, @VDC Supplier<ReferenceType> defaultVDC) {
super(orgVDCMap, defaultOrg, defaultVDC);
}

View File

@ -41,13 +41,13 @@ import com.google.common.collect.Iterables;
public abstract class OrgNameVDCNameResourceNameToEndpoint implements Function<Object, URI>{
protected final Supplier<Map<String, Map<String, ? extends org.jclouds.trmk.vcloud_0_8.domain.VDC>>> orgVDCMap;
protected final ReferenceType defaultOrg;
protected final ReferenceType defaultVDC;
protected final Supplier<ReferenceType> defaultOrg;
protected final Supplier<ReferenceType> defaultVDC;
@Inject
public OrgNameVDCNameResourceNameToEndpoint(
Supplier<Map<String, Map<String, ? extends org.jclouds.trmk.vcloud_0_8.domain.VDC>>> orgVDCMap,
@Org ReferenceType defaultOrg, @org.jclouds.trmk.vcloud_0_8.endpoints.VDC ReferenceType defaultVDC) {
@Org Supplier<ReferenceType> defaultOrg, @org.jclouds.trmk.vcloud_0_8.endpoints.VDC Supplier<ReferenceType> defaultVDC) {
this.orgVDCMap = orgVDCMap;
this.defaultOrg = defaultOrg;
this.defaultVDC = defaultVDC;
@ -60,9 +60,9 @@ public abstract class OrgNameVDCNameResourceNameToEndpoint implements Function<
Object vDC = Iterables.get(orgVDC, 1);
Object resource = Iterables.get(orgVDC, 2);
if (org == null)
org = defaultOrg.getName();
org = defaultOrg.get().getName();
if (vDC == null)
vDC = defaultVDC.getName();
vDC = defaultVDC.get().getName();
Map<String, Map<String, ? extends org.jclouds.trmk.vcloud_0_8.domain.VDC>> orgToVDCs = orgVDCMap.get();
checkState(orgToVDCs != null, "could not get map of org name to vdcs!");
Map<String, ? extends org.jclouds.trmk.vcloud_0_8.domain.VDC> vDCs = orgToVDCs.get(org);

View File

@ -36,10 +36,10 @@ import com.google.common.collect.Maps;
public abstract class OrgURIToEndpoint implements Function<Object, URI> {
protected final Supplier<Map<String, ? extends Org>> orgMap;
protected final ReferenceType defaultOrg;
protected final Supplier<ReferenceType> defaultOrg;
public OrgURIToEndpoint(Supplier<Map<String, ? extends Org>> orgMap,
@org.jclouds.trmk.vcloud_0_8.endpoints.Org ReferenceType defaultUri) {
@org.jclouds.trmk.vcloud_0_8.endpoints.Org Supplier<ReferenceType> defaultUri) {
this.orgMap = orgMap;
this.defaultOrg = defaultUri;
}
@ -54,7 +54,7 @@ public abstract class OrgURIToEndpoint implements Function<Object, URI> {
});
try {
Org org = uriToOrg.get(from == null ? defaultOrg.getHref() : from);
Org org = uriToOrg.get(from == null ? defaultOrg.get().getHref() : from);
return getUriFromOrg(org);
} catch (NullPointerException e) {
throw new ResourceNotFoundException("org " + from + " not found in: " + uriToOrg, e);

View File

@ -38,7 +38,7 @@ import com.google.common.base.Supplier;
public class OrgURIToKeysListEndpoint extends OrgURIToEndpoint implements Function<Object, URI> {
@Inject
public OrgURIToKeysListEndpoint(Supplier<Map<String, ? extends Org>> orgMap,
@org.jclouds.trmk.vcloud_0_8.endpoints.Org ReferenceType defaultUri) {
@org.jclouds.trmk.vcloud_0_8.endpoints.Org Supplier<ReferenceType> defaultUri) {
super(orgMap, defaultUri);
}

View File

@ -38,18 +38,18 @@ import com.google.common.base.Supplier;
@Singleton
public class VDCURIToInternetServicesEndpoint implements Function<Object, URI> {
private final Supplier<Map<URI, ? extends org.jclouds.trmk.vcloud_0_8.domain.VDC>> orgVDCMap;
private final ReferenceType defaultVDC;
private final Supplier<ReferenceType> defaultVDC;
@Inject
public VDCURIToInternetServicesEndpoint(
Supplier<Map<URI, ? extends org.jclouds.trmk.vcloud_0_8.domain.VDC>> orgVDCMap, @VDC ReferenceType defaultVDC) {
Supplier<Map<URI, ? extends org.jclouds.trmk.vcloud_0_8.domain.VDC>> orgVDCMap, @VDC Supplier<ReferenceType> defaultVDC) {
this.orgVDCMap = orgVDCMap;
this.defaultVDC = defaultVDC;
}
public URI apply(Object from) {
try {
return orgVDCMap.get().get(from == null ? defaultVDC.getHref() : from).getInternetServices().getHref();
return orgVDCMap.get().get(from == null ? defaultVDC.get().getHref() : from).getInternetServices().getHref();
} catch (NullPointerException e) {
throw new ResourceNotFoundException("vdc " + from + " not found in " + orgVDCMap.get());
}

View File

@ -38,18 +38,18 @@ import com.google.common.base.Supplier;
@Singleton
public class VDCURIToPublicIPsEndpoint implements Function<Object, URI> {
private final Supplier<Map<URI, ? extends org.jclouds.trmk.vcloud_0_8.domain.VDC>> orgVDCMap;
private final ReferenceType defaultVDC;
private final Supplier<ReferenceType> defaultVDC;
@Inject
public VDCURIToPublicIPsEndpoint(Supplier<Map<URI, ? extends org.jclouds.trmk.vcloud_0_8.domain.VDC>> orgVDCMap,
@VDC ReferenceType defaultVDC) {
@VDC Supplier<ReferenceType> defaultVDC) {
this.orgVDCMap = orgVDCMap;
this.defaultVDC = defaultVDC;
}
public URI apply(Object from) {
try {
return orgVDCMap.get().get(from == null ? defaultVDC.getHref() : from).getPublicIps().getHref();
return orgVDCMap.get().get(from == null ? defaultVDC.get().getHref() : from).getPublicIps().getHref();
} catch (NullPointerException e) {
throw new ResourceNotFoundException("vdc " + from + " not found in " + orgVDCMap.get());
}

View File

@ -40,16 +40,16 @@ import com.google.common.base.Supplier;
public class DefaultVDC implements ImplicitLocationSupplier {
@Singleton
public static final class IsDefaultVDC implements Predicate<Location> {
private final ReferenceType defaultVDC;
private final Supplier<ReferenceType> defaultVDC;
@Inject
IsDefaultVDC(@VDC ReferenceType defaultVDC) {
IsDefaultVDC(@VDC Supplier<ReferenceType> defaultVDC) {
this.defaultVDC = checkNotNull(defaultVDC, "defaultVDC");
}
@Override
public boolean apply(Location input) {
return input.getScope() == LocationScope.ZONE && input.getId().equals(defaultVDC.getHref().toASCIIString());
return input.getScope() == LocationScope.ZONE && input.getId().equals(defaultVDC.get().getHref().toASCIIString());
}
@Override

View File

@ -41,6 +41,8 @@ import org.nnsoft.guice.rocoto.Rocoto;
import org.nnsoft.guice.rocoto.configuration.ConfigurationModule;
import org.testng.annotations.Test;
import com.google.common.base.Supplier;
import com.google.common.base.Suppliers;
import com.google.common.collect.HashMultimap;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Maps;
@ -68,8 +70,9 @@ public class BindInstantiateVAppTemplateParamsToXmlPayloadTest {
@Network
@Provides
@Singleton
ReferenceType provideNetwork() {
return new ReferenceTypeImpl(null, null, URI.create("https://vcloud.safesecureweb.com/network/1990"));
Supplier<ReferenceType> provideNetwork() {
return Suppliers.<ReferenceType>ofInstance(new ReferenceTypeImpl(null, null, URI
.create("https://vcloud.safesecureweb.com/network/1990")));
}
}));

View File

@ -676,8 +676,8 @@ public abstract class BaseComputeServiceLiveTest extends BaseVersionedServiceLiv
format("ls %s/bundles/org/jboss/as/osgi/configadmin/main|sed -e 's/.*-//g' -e 's/.jar//g'",
JBOSS_HOME)), configureSeconds));
for (Entry<String, URI> download : ImmutableMap.<String, URI> of("jboss7", JBOSS7_URL, "jdk7", InstallJDK.FromURL.JDK7_URL)
.entrySet()) {
for (Entry<String, URI> download : ImmutableMap.<String, URI> of("jboss7", JBOSS7_URL, "jdk7",
URI.create("http://download.oracle.com/otn-pub/java/jdk/7/jdk-7-linux-x64.tar.gz")).entrySet()) {
// note we cannot use nslookup until we've configured the system, as
// it may have not been present checking the address of the download
// host using the local node's DNS config

View File

@ -133,6 +133,42 @@ function setupPublicCurl() {
ensure_can_resolve_public_dns
return 0
}
function installJDK() {
if hash curl 2>/dev/null; then
if [ `uname -m` == 'x86_64' ]; then
local url=${1:-http://download.oracle.com/otn-pub/java/jdk/7/jdk-7-linux-x64.tar.gz}
else
local url=${1:-http://download.oracle.com/otn-pub/java/jdk/7/jdk-7-linux-i586.tar.gz}
fi
curl -q -s -S -L --connect-timeout 10 --max-time 600 --retry 20 -X GET $url |(mkdir -p /usr/local &&cd /usr/local &&tar -xpzf -)
mv /usr/local/jdk* /usr/local/jdk/
test -n \"$SUDO_USER\" && cat >> /home/$SUDO_USER/.bashrc <<-'END_OF_JCLOUDS_FILE'
export JAVA_HOME=/usr/local/jdk
export PATH=$JAVA_HOME/bin:$PATH
END_OF_JCLOUDS_FILE
cat >> /etc/bashrc <<-'END_OF_JCLOUDS_FILE'
export JAVA_HOME=/usr/local/jdk
export PATH=$JAVA_HOME/bin:$PATH
END_OF_JCLOUDS_FILE
cat >> $HOME/.bashrc <<-'END_OF_JCLOUDS_FILE'
export JAVA_HOME=/usr/local/jdk
export PATH=$JAVA_HOME/bin:$PATH
END_OF_JCLOUDS_FILE
cat >> /etc/skel/.bashrc <<-'END_OF_JCLOUDS_FILE'
export JAVA_HOME=/usr/local/jdk
export PATH=$JAVA_HOME/bin:$PATH
END_OF_JCLOUDS_FILE
# TODO: eventhough we are setting the above, sometimes images (ex.
# cloudservers ubuntu) kick out of .bashrc (ex. [ -z "$PS1" ] &&
# return), for this reason, we should also explicitly link.
# A better way would be to update using alternatives or the like
ln -fs /usr/local/jdk/bin/java /usr/bin/java
/usr/bin/java -version || abort "cannot run /usr/bin/java"
else
abort "curl not available.. cannot install openjdk"
fi
return 0
}
END_OF_JCLOUDS_SCRIPT
@ -162,26 +198,7 @@ END_OF_JCLOUDS_SCRIPT
awk -v user=^${SUDO_USER:=${USER}}: -v password='crypt(randompassword)' 'BEGIN { FS=OFS=":" } $0 ~ user { $2 = password } 1' /etc/shadow >/etc/shadow.${SUDO_USER:=${USER}}
test -f /etc/shadow.${SUDO_USER:=${USER}} && mv /etc/shadow.${SUDO_USER:=${USER}} /etc/shadow
setupPublicCurl || return 1
curl -q -s -S -L --connect-timeout 10 --max-time 600 --retry 20 -X GET http://download.oracle.com/otn-pub/java/jdk/7/jdk-7-linux-x64.tar.gz |(mkdir -p /usr/local &&cd /usr/local &&tar -xpzf -)
mv /usr/local/jdk* /usr/local/jdk/
test -n "$SUDO_USER" &&
cat >> /home/$SUDO_USER/.bashrc <<-'END_OF_JCLOUDS_FILE'
export JAVA_HOME=/usr/local/jdk
export PATH=$JAVA_HOME/bin:$PATH
END_OF_JCLOUDS_FILE
cat >> /etc/bashrc <<-'END_OF_JCLOUDS_FILE'
export JAVA_HOME=/usr/local/jdk
export PATH=$JAVA_HOME/bin:$PATH
END_OF_JCLOUDS_FILE
cat >> $HOME/.bashrc <<-'END_OF_JCLOUDS_FILE'
export JAVA_HOME=/usr/local/jdk
export PATH=$JAVA_HOME/bin:$PATH
END_OF_JCLOUDS_FILE
cat >> /etc/skel/.bashrc <<-'END_OF_JCLOUDS_FILE'
export JAVA_HOME=/usr/local/jdk
export PATH=$JAVA_HOME/bin:$PATH
END_OF_JCLOUDS_FILE
ln -fs /usr/local/jdk/bin/java /usr/bin/java
installJDK || return 1
END_OF_JCLOUDS_SCRIPT

View File

@ -133,6 +133,42 @@ function setupPublicCurl() {
ensure_can_resolve_public_dns
return 0
}
function installJDK() {
if hash curl 2>/dev/null; then
if [ `uname -m` == 'x86_64' ]; then
local url=${1:-http://download.oracle.com/otn-pub/java/jdk/7/jdk-7-linux-x64.tar.gz}
else
local url=${1:-http://download.oracle.com/otn-pub/java/jdk/7/jdk-7-linux-i586.tar.gz}
fi
curl -q -s -S -L --connect-timeout 10 --max-time 600 --retry 20 -X GET $url |(mkdir -p /usr/local &&cd /usr/local &&tar -xpzf -)
mv /usr/local/jdk* /usr/local/jdk/
test -n \"$SUDO_USER\" && cat >> /home/$SUDO_USER/.bashrc <<-'END_OF_JCLOUDS_FILE'
export JAVA_HOME=/usr/local/jdk
export PATH=$JAVA_HOME/bin:$PATH
END_OF_JCLOUDS_FILE
cat >> /etc/bashrc <<-'END_OF_JCLOUDS_FILE'
export JAVA_HOME=/usr/local/jdk
export PATH=$JAVA_HOME/bin:$PATH
END_OF_JCLOUDS_FILE
cat >> $HOME/.bashrc <<-'END_OF_JCLOUDS_FILE'
export JAVA_HOME=/usr/local/jdk
export PATH=$JAVA_HOME/bin:$PATH
END_OF_JCLOUDS_FILE
cat >> /etc/skel/.bashrc <<-'END_OF_JCLOUDS_FILE'
export JAVA_HOME=/usr/local/jdk
export PATH=$JAVA_HOME/bin:$PATH
END_OF_JCLOUDS_FILE
# TODO: eventhough we are setting the above, sometimes images (ex.
# cloudservers ubuntu) kick out of .bashrc (ex. [ -z "$PS1" ] &&
# return), for this reason, we should also explicitly link.
# A better way would be to update using alternatives or the like
ln -fs /usr/local/jdk/bin/java /usr/bin/java
/usr/bin/java -version || abort "cannot run /usr/bin/java"
else
abort "curl not available.. cannot install openjdk"
fi
return 0
}
END_OF_JCLOUDS_SCRIPT
@ -162,26 +198,7 @@ END_OF_JCLOUDS_SCRIPT
awk -v user=^${SUDO_USER:=${USER}}: -v password='crypt(randompassword)' 'BEGIN { FS=OFS=":" } $0 ~ user { $2 = password } 1' /etc/shadow >/etc/shadow.${SUDO_USER:=${USER}}
test -f /etc/shadow.${SUDO_USER:=${USER}} && mv /etc/shadow.${SUDO_USER:=${USER}} /etc/shadow
setupPublicCurl || return 1
curl -q -s -S -L --connect-timeout 10 --max-time 600 --retry 20 -X GET http://download.oracle.com/otn-pub/java/jdk/7/jdk-7-linux-x64.tar.gz |(mkdir -p /usr/local &&cd /usr/local &&tar -xpzf -)
mv /usr/local/jdk* /usr/local/jdk/
test -n "$SUDO_USER" &&
cat >> /home/$SUDO_USER/.bashrc <<-'END_OF_JCLOUDS_FILE'
export JAVA_HOME=/usr/local/jdk
export PATH=$JAVA_HOME/bin:$PATH
END_OF_JCLOUDS_FILE
cat >> /etc/bashrc <<-'END_OF_JCLOUDS_FILE'
export JAVA_HOME=/usr/local/jdk
export PATH=$JAVA_HOME/bin:$PATH
END_OF_JCLOUDS_FILE
cat >> $HOME/.bashrc <<-'END_OF_JCLOUDS_FILE'
export JAVA_HOME=/usr/local/jdk
export PATH=$JAVA_HOME/bin:$PATH
END_OF_JCLOUDS_FILE
cat >> /etc/skel/.bashrc <<-'END_OF_JCLOUDS_FILE'
export JAVA_HOME=/usr/local/jdk
export PATH=$JAVA_HOME/bin:$PATH
END_OF_JCLOUDS_FILE
ln -fs /usr/local/jdk/bin/java /usr/bin/java
installJDK || return 1
iptables -I INPUT 1 -p tcp --dport 22 -j ACCEPT
iptables -I INPUT 1 -p tcp --dport 8080 -j ACCEPT
iptables-save

View File

@ -133,6 +133,42 @@ function setupPublicCurl() {
ensure_can_resolve_public_dns
return 0
}
function installJDK() {
if hash curl 2>/dev/null; then
if [ `uname -m` == 'x86_64' ]; then
local url=${1:-http://download.oracle.com/otn-pub/java/jdk/7/jdk-7-linux-x64.tar.gz}
else
local url=${1:-http://download.oracle.com/otn-pub/java/jdk/7/jdk-7-linux-i586.tar.gz}
fi
curl -q -s -S -L --connect-timeout 10 --max-time 600 --retry 20 -X GET $url |(mkdir -p /usr/local &&cd /usr/local &&tar -xpzf -)
mv /usr/local/jdk* /usr/local/jdk/
test -n \"$SUDO_USER\" && cat >> /home/$SUDO_USER/.bashrc <<-'END_OF_JCLOUDS_FILE'
export JAVA_HOME=/usr/local/jdk
export PATH=$JAVA_HOME/bin:$PATH
END_OF_JCLOUDS_FILE
cat >> /etc/bashrc <<-'END_OF_JCLOUDS_FILE'
export JAVA_HOME=/usr/local/jdk
export PATH=$JAVA_HOME/bin:$PATH
END_OF_JCLOUDS_FILE
cat >> $HOME/.bashrc <<-'END_OF_JCLOUDS_FILE'
export JAVA_HOME=/usr/local/jdk
export PATH=$JAVA_HOME/bin:$PATH
END_OF_JCLOUDS_FILE
cat >> /etc/skel/.bashrc <<-'END_OF_JCLOUDS_FILE'
export JAVA_HOME=/usr/local/jdk
export PATH=$JAVA_HOME/bin:$PATH
END_OF_JCLOUDS_FILE
# TODO: eventhough we are setting the above, sometimes images (ex.
# cloudservers ubuntu) kick out of .bashrc (ex. [ -z "$PS1" ] &&
# return), for this reason, we should also explicitly link.
# A better way would be to update using alternatives or the like
ln -fs /usr/local/jdk/bin/java /usr/bin/java
/usr/bin/java -version || abort "cannot run /usr/bin/java"
else
abort "curl not available.. cannot install openjdk"
fi
return 0
}
END_OF_JCLOUDS_SCRIPT
@ -142,26 +178,7 @@ END_OF_JCLOUDS_SCRIPT
rm -f $INSTANCE_HOME/rc
trap 'echo $?>$INSTANCE_HOME/rc' 0 1 2 3 15
setupPublicCurl || exit 1
curl -q -s -S -L --connect-timeout 10 --max-time 600 --retry 20 -X GET http://download.oracle.com/otn-pub/java/jdk/7/jdk-7-linux-x64.tar.gz |(mkdir -p /usr/local &&cd /usr/local &&tar -xpzf -)
mv /usr/local/jdk* /usr/local/jdk/
test -n "$SUDO_USER" &&
cat >> /home/$SUDO_USER/.bashrc <<-'END_OF_JCLOUDS_FILE'
export JAVA_HOME=/usr/local/jdk
export PATH=$JAVA_HOME/bin:$PATH
END_OF_JCLOUDS_FILE
cat >> /etc/bashrc <<-'END_OF_JCLOUDS_FILE'
export JAVA_HOME=/usr/local/jdk
export PATH=$JAVA_HOME/bin:$PATH
END_OF_JCLOUDS_FILE
cat >> $HOME/.bashrc <<-'END_OF_JCLOUDS_FILE'
export JAVA_HOME=/usr/local/jdk
export PATH=$JAVA_HOME/bin:$PATH
END_OF_JCLOUDS_FILE
cat >> /etc/skel/.bashrc <<-'END_OF_JCLOUDS_FILE'
export JAVA_HOME=/usr/local/jdk
export PATH=$JAVA_HOME/bin:$PATH
END_OF_JCLOUDS_FILE
ln -fs /usr/local/jdk/bin/java /usr/bin/java
installJDK || exit 1
END_OF_JCLOUDS_SCRIPT

View File

@ -47,8 +47,8 @@
<!-- only required for Pems.java and only writing a private key file -->
<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcprov-jdk15</artifactId>
<version>1.44</version>
<artifactId>bcprov-jdk16</artifactId>
<version>1.46</version>
<optional>true</optional>
</dependency>
<dependency>
@ -59,7 +59,7 @@
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-core</artifactId>
<version>1.11</version>
<version>1.12</version>
</dependency>
<dependency>
<groupId>com.google.inject.extensions</groupId>
@ -99,7 +99,7 @@
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>11.0.1</version>
<version>11.0.2</version>
</dependency>
</dependencies>
@ -107,7 +107,7 @@
<plugins>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>2.3.1</version>
<version>2.4</version>
<executions>
<execution>
<goals>

View File

@ -106,10 +106,10 @@ public class BackoffLimitedRetryHandler implements HttpRetryHandler, IOException
command.incrementFailureCount();
if (!command.isReplayable()) {
logger.warn("Cannot retry after server error, command is not replayable: %1$s", command);
logger.error("Cannot retry after server error, command is not replayable: %1$s", command);
return false;
} else if (command.getFailureCount() > retryCountLimit) {
logger.warn("Cannot retry after server error, command has exceeded retry limit %1$d: %2$s", retryCountLimit,
logger.error("Cannot retry after server error, command has exceeded retry limit %1$d: %2$s", retryCountLimit,
command);
return false;
} else {

View File

@ -22,6 +22,9 @@ aws-simpledb.propertiesbuilder=org.jclouds.aws.simpledb.AWSSimpleDBPropertiesBui
aws-sqs.contextbuilder=org.jclouds.sqs.SQSContextBuilder
aws-sqs.propertiesbuilder=org.jclouds.aws.sqs.AWSSQSPropertiesBuilder
elb.contextbuilder=org.jclouds.elb.ELBContextBuilder
elb.propertiesbuilder=org.jclouds.elb.ELBPropertiesBuilder
aws-elb.contextbuilder=org.jclouds.elb.ELBContextBuilder
aws-elb.propertiesbuilder=org.jclouds.aws.elb.AWSELBPropertiesBuilder
@ -183,6 +186,9 @@ softlayer.propertiesbuilder=org.jclouds.softlayer.SoftLayerPropertiesBuilder
glesys.contextbuilder=org.jclouds.glesys.GleSYSContextBuilder
glesys.propertiesbuilder=org.jclouds.glesys.GleSYSPropertiesBuilder
opsource-servers.contextbuilder=org.jclouds.opsource.servers.OpSourceServersContextBuilder
opsource-servers.propertiesbuilder=org.jclouds.opsource.servers.OpSourceServersPropertiesBuilder
savvis-symphonyvpdc.contextbuilder=org.jclouds.savvis.vpdc.VPDCContextBuilder
savvis-symphonyvpdc.propertiesbuilder=org.jclouds.savvis.vpdc.VPDCPropertiesBuilder

View File

@ -45,13 +45,13 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.ws.rs.core.HttpHeaders;
import org.eclipse.jetty.http.ssl.SslContextFactory;
import org.eclipse.jetty.server.Connector;
import org.eclipse.jetty.server.Handler;
import org.eclipse.jetty.server.Request;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.handler.AbstractHandler;
import org.eclipse.jetty.server.ssl.SslSelectChannelConnector;
import org.eclipse.jetty.util.ssl.SslContextFactory;
import org.jclouds.Constants;
import org.jclouds.crypto.CryptoStreams;
import org.jclouds.io.InputSuppliers;

View File

@ -39,6 +39,11 @@ import javax.inject.Inject;
import javax.inject.Named;
import javax.inject.Singleton;
import org.custommonkey.xmlunit.Diff;
import org.custommonkey.xmlunit.Difference;
import org.custommonkey.xmlunit.DifferenceConstants;
import org.custommonkey.xmlunit.DifferenceListener;
import org.custommonkey.xmlunit.XMLUnit;
import org.jclouds.Constants;
import org.jclouds.concurrent.MoreExecutors;
import org.jclouds.concurrent.SingleThreaded;
@ -58,14 +63,18 @@ import org.jclouds.io.Payloads;
import org.jclouds.logging.config.NullLoggingModule;
import org.jclouds.util.Strings2;
import org.testng.annotations.Test;
import org.w3c.dom.Node;
import com.google.common.annotations.Beta;
import com.google.common.base.Function;
import com.google.common.base.Objects;
import com.google.common.base.Throwables;
import com.google.common.collect.ImmutableBiMap;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import com.google.gson.JsonElement;
import com.google.gson.JsonParser;
import com.google.inject.AbstractModule;
import com.google.inject.Binder;
import com.google.inject.Module;
@ -324,7 +333,9 @@ public abstract class BaseRestClientExpectTest<S> {
return HttpResponse.builder().statusCode(500).message(
String.format("request %s is out of range (%s)", index, requests.size())).payload(
Payloads.newStringPayload(renderRequest(input))).build();
assertEquals(renderRequest(input), renderRequest(requests.get(index)));
if (!httpRequestsAreEqual(input, requests.get(index))) {
assertEquals(renderRequest(input), renderRequest(requests.get(index)));
}
return responses.get(index);
}
});
@ -342,14 +353,81 @@ public abstract class BaseRestClientExpectTest<S> {
return requestsSendResponses(requestToResponse, createModule());
}
protected enum HttpRequestComparisonType {
XML, JSON, DEFAULT;
}
/**
* How should this HttpRequest be compared with others?
*/
protected HttpRequestComparisonType compareHttpRequestAsType(HttpRequest input) {
return HttpRequestComparisonType.DEFAULT;
}
/**
* Compare two requests as instructed by {@link #compareHttpRequestAsType(HttpRequest)} - default is to compare using Objects.equal
*/
public boolean httpRequestsAreEqual(HttpRequest a, HttpRequest b) {
try {
switch (compareHttpRequestAsType(a)) {
case XML: {
if (a == null || b == null || a.getPayload() == null || b.getPayload() == null) {
return false;
}
Diff diff = XMLUnit.compareXML(Strings2.toStringAndClose(a.getPayload().getInput()),
Strings2.toStringAndClose(b.getPayload().getInput()));
// Ignoring xsi:schemaLocation and differences in namespace prefixes
diff.overrideDifferenceListener(new DifferenceListener() {
@Override
public int differenceFound(Difference difference) {
if (difference.getId() == DifferenceConstants.SCHEMA_LOCATION_ID ||
difference.getId() == DifferenceConstants.NAMESPACE_PREFIX_ID) {
return RETURN_IGNORE_DIFFERENCE_NODES_IDENTICAL;
}
return RETURN_ACCEPT_DIFFERENCE;
}
@Override
public void skippedComparison(Node node, Node node1) {
}
});
return diff.identical() && Objects.equal(a.getHeaders(), b.getHeaders());
}
case JSON: {
if (a == null || b == null || a.getPayload() == null || b.getPayload() == null) {
return false;
}
JsonParser parser = new JsonParser();
JsonElement payloadA = parser.parse(Strings2.toStringAndClose(a.getPayload().getInput()));
JsonElement payloadB = parser.parse(Strings2.toStringAndClose(b.getPayload().getInput()));
return Objects.equal(payloadA, payloadB) && Objects.equal(a.getHeaders(), b.getHeaders());
}
default: {
return Objects.equal(a, b);
}
}
} catch (Exception e) {
throw Throwables.propagate(e);
}
}
public S requestsSendResponses(final Map<HttpRequest, HttpResponse> requestToResponse, Module module) {
return createClient(new Function<HttpRequest, HttpResponse>() {
ImmutableBiMap<HttpRequest, HttpResponse> bimap = ImmutableBiMap.copyOf(requestToResponse);
@Override
public HttpResponse apply(HttpRequest input) {
if (!(requestToResponse.containsKey(input))) {
HttpResponse response = null;
for (HttpRequest request : requestToResponse.keySet()) {
if (httpRequestsAreEqual(input, request)) {
response = requestToResponse.get(request);
}
}
if (response == null) {
StringBuilder payload = new StringBuilder("\n");
payload.append("the following request is not configured:\n");
payload.append("----------------------------------------\n");
@ -360,13 +438,14 @@ public abstract class BaseRestClientExpectTest<S> {
payload.append("----------------------------------------\n");
payload.append(renderRequest(request));
}
return HttpResponse.builder().statusCode(500).message("no response configured for request").payload(
Payloads.newStringPayload(payload.toString())).build();
response = HttpResponse.builder().statusCode(500).message("no response configured for request").payload(
Payloads.newStringPayload(payload.toString())).build();
} else if (compareHttpRequestAsType(input) == HttpRequestComparisonType.DEFAULT) {
// in case hashCode/equals doesn't do a full content check
assertEquals(renderRequest(input), renderRequest(bimap.inverse().get(response)));
}
HttpResponse response = requestToResponse.get(input);
// in case hashCode/equals doesn't do a full content check
assertEquals(renderRequest(input), renderRequest(bimap.inverse().get(response)));
return response;
}
}, module);

View File

@ -60,7 +60,7 @@
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.1.1</version>
<version>4.1.3</version>
<scope>compile</scope>
</dependency>
<dependency>

View File

@ -60,7 +60,7 @@
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>1.6.2</version>
<version>2.1</version>
<scope>compile</scope>
</dependency>
</dependencies>

View File

@ -78,7 +78,7 @@
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>0.9.30</version>
<version>1.0.0</version>
<scope>test</scope>
</dependency>
<dependency>

View File

@ -33,30 +33,6 @@
<description>jclouds netty payload module</description>
<packaging>bundle</packaging>
<!-- bootstrapping: need to fetch the project POM -->
<repositories>
<repository>
<id>jclouds-sona-snapshots-nexus</id>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
<repository>
<id>jboss-public-releases</id>
<url>https://repository.jboss.org/nexus/content/groups/public-jboss</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.jclouds</groupId>
@ -71,9 +47,9 @@
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.netty</groupId>
<groupId>io.netty</groupId>
<artifactId>netty</artifactId>
<version>3.2.4.Final</version>
<version>3.3.1.Final</version>
<scope>compile</scope>
</dependency>
</dependencies>

View File

@ -60,7 +60,7 @@
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.6.1</version>
<version>1.6.4</version>
<scope>compile</scope>
</dependency>
</dependencies>

View File

@ -71,7 +71,7 @@
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>0.9.30</version>
<version>1.0.0</version>
<scope>test</scope>
</dependency>
<dependency>

View File

@ -27,7 +27,7 @@
<version>1.5.0-SNAPSHOT</version>
<relativePath>../../project/pom.xml</relativePath>
</parent>
<groupId>org.jclouds.provider</groupId>
<groupId>org.jclouds.labs</groupId>
<artifactId>aws-elb</artifactId>
<name>jclouds Amazon Elastic Load Balancer provider</name>
<description>Elastic Load Balancer implementation targeted to Amazon Web Services</description>
@ -50,13 +50,13 @@
<dependencies>
<dependency>
<groupId>org.jclouds.api</groupId>
<groupId>org.jclouds.labs</groupId>
<artifactId>elb</artifactId>
<version>${project.version}</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>org.jclouds.api</groupId>
<groupId>org.jclouds.labs</groupId>
<artifactId>elb</artifactId>
<version>${project.version}</version>
<type>test-jar</type>

View File

@ -69,10 +69,6 @@ public class AWSELBPropertiesBuilder extends ELBPropertiesBuilder {
return properties;
}
public AWSELBPropertiesBuilder() {
super();
}
public AWSELBPropertiesBuilder(Properties properties) {
super(properties);
}

View File

@ -27,7 +27,7 @@ import org.testng.annotations.Test;
*
* @author Adrian Cole
*/
@Test(groups = "live", sequential = true, testName = "AWSELBClientLiveTest")
@Test(groups = "live", singleThreaded = true, testName = "AWSELBClientLiveTest")
public class AWSELBClientLiveTest extends ELBClientLiveTest {
public AWSELBClientLiveTest() {
provider = "aws-elb";
@ -47,7 +47,7 @@ public class AWSELBClientLiveTest extends ELBClientLiveTest {
}
}
@Test
@Test(dependsOnMethods = "testDescribeLoadBalancers")
public void testDeleteLoadBalancer() {
for (String region : Region.DEFAULT_REGIONS) {
deleteLoadBalancerInRegion(region);

View File

@ -27,7 +27,7 @@
<version>1.5.0-SNAPSHOT</version>
<relativePath>../../project/pom.xml</relativePath>
</parent>
<groupId>org.jclouds.api</groupId>
<groupId>org.jclouds.labs</groupId>
<artifactId>elb</artifactId>
<name>jcloud elb api</name>
<description>jclouds components to access an implementation of Elastic Load Balancer</description>
@ -40,7 +40,7 @@
<test.elb.build-version></test.elb.build-version>
<test.elb.identity>${test.aws.identity}</test.elb.identity>
<test.elb.credential>${test.aws.credential}</test.elb.credential>
<test.elb.compute.provider>ec2</test.elb.compute.provider>
<test.elb.compute.provider>aws-ec2</test.elb.compute.provider>
<test.elb.compute.endpoint>https://ec2.us-east-1.amazonaws.com</test.elb.compute.endpoint>
<test.elb.compute.api-version>2010-06-15</test.elb.compute.api-version>
<test.elb.compute.build-version></test.elb.compute.build-version>
@ -75,6 +75,12 @@
<type>test-jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jclouds.provider</groupId>
<artifactId>aws-ec2</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jclouds.driver</groupId>
<artifactId>jclouds-sshj</artifactId>

View File

@ -43,9 +43,6 @@ public class ELBPropertiesBuilder extends PropertiesBuilder {
return properties;
}
public ELBPropertiesBuilder() {
super();
}
public ELBPropertiesBuilder(Properties properties) {
super(properties);

View File

@ -30,7 +30,6 @@ public class ELBLoadBalancerContextModule extends BaseLoadBalancerServiceContext
@Override
protected void configure() {
install(new ELBBindLoadBalancerSuppliersByClass());
install(new ELBBindLoadBalancerStrategiesByClass());
install(new ELBLoadBalancerServiceDependenciesModule());
super.configure();

View File

@ -18,21 +18,27 @@
*/
package org.jclouds.elb.loadbalancer.functions;
import java.util.Map;
import java.util.NoSuchElementException;
import java.util.Set;
import javax.annotation.Resource;
import javax.inject.Inject;
import javax.inject.Singleton;
import org.jclouds.collect.Memoized;
import org.jclouds.domain.Location;
import org.jclouds.elb.domain.LoadBalancer;
import org.jclouds.loadbalancer.domain.LoadBalancerMetadata;
import org.jclouds.loadbalancer.domain.LoadBalancerType;
import org.jclouds.loadbalancer.domain.internal.LoadBalancerMetadataImpl;
import org.jclouds.logging.Logger;
import com.google.common.base.Function;
import com.google.common.base.Predicate;
import com.google.common.base.Supplier;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Iterables;
/**
*
@ -40,25 +46,49 @@ import com.google.common.collect.ImmutableSet;
*/
@Singleton
public class LoadBalancerToLoadBalancerMetadata implements Function<LoadBalancer, LoadBalancerMetadata> {
protected final Supplier<Map<String, ? extends Location>> locationMap;
@Resource
protected static Logger logger = Logger.NULL;
protected final Supplier<Set<? extends Location>> locations;
protected final Supplier<Location> defaultLocationSupplier;
@Inject
public LoadBalancerToLoadBalancerMetadata(Supplier<Location> defaultLocationSupplier,
Supplier<Map<String, ? extends Location>> locationMap) {
this.locationMap = locationMap;
@Memoized Supplier<Set<? extends Location>> locations) {
this.locations = locations;
this.defaultLocationSupplier = defaultLocationSupplier;
}
@Override
public LoadBalancerMetadata apply(LoadBalancer input) {
Location location = input.getRegion() != null ? locationMap.get().get(input.getRegion())
: defaultLocationSupplier.get();
Location location = input.getRegion() != null ? findLocationWithId(input.getRegion()) : defaultLocationSupplier
.get();
String id = input.getRegion() != null ? input.getRegion() + "/" + input.getName() : input.getName();
// TODO Builder
return new LoadBalancerMetadataImpl(LoadBalancerType.LB, input.getName(), input.getName(), id, location, null,
ImmutableMap.<String, String> of(), ImmutableSet.of(input.getDnsName()));
ImmutableMap.<String, String> of(), ImmutableSet.of(input.getDnsName()));
}
private Location findLocationWithId(final String locationId) {
if (locationId == null)
return null;
try {
Location location = Iterables.find(locations.get(), new Predicate<Location>() {
@Override
public boolean apply(Location input) {
return input.getId().equals(locationId);
}
});
return location;
} catch (NoSuchElementException e) {
logger.debug("couldn't match instance location %s in: %s", locationId, locations.get());
return null;
}
}
}

View File

@ -27,7 +27,6 @@ import java.util.Set;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Future;
import javax.annotation.Nullable;
import javax.annotation.Resource;
import javax.inject.Inject;
import javax.inject.Named;
@ -44,6 +43,7 @@ import org.jclouds.location.Region;
import org.jclouds.logging.Logger;
import com.google.common.base.Function;
import com.google.common.base.Supplier;
import com.google.common.util.concurrent.ListenableFuture;
/**
@ -60,12 +60,12 @@ public class ELBListLoadBalancersStrategy implements ListLoadBalancersStrategy {
private final ELBAsyncClient aclient;
private final Function<LoadBalancer, LoadBalancerMetadata> converter;
private final ExecutorService executor;
private final Set<String> regions;
private final Supplier<Set<String>> regions;
@Inject
protected ELBListLoadBalancersStrategy(ELBClient client, ELBAsyncClient aclient,
Function<LoadBalancer, LoadBalancerMetadata> converter,
@Named(Constants.PROPERTY_USER_THREADS) ExecutorService executor, @Nullable @Region Set<String> regions) {
Function<LoadBalancer, LoadBalancerMetadata> converter,
@Named(Constants.PROPERTY_USER_THREADS) ExecutorService executor, @Region Supplier<Set<String>> regions) {
this.client = checkNotNull(client, "client");
this.aclient = checkNotNull(aclient, "aclient");
this.regions = checkNotNull(regions, "regions");
@ -76,7 +76,8 @@ public class ELBListLoadBalancersStrategy implements ListLoadBalancersStrategy {
@Override
public Iterable<? extends LoadBalancerMetadata> listLoadBalancers() {
Iterable<? extends LoadBalancer> loadBalancers;
if (regions != null)
Set<String> regions = this.regions.get();
if (regions.size() > 0)
loadBalancers = concat(transformParallel(regions, new Function<String, Future<Set<? extends LoadBalancer>>>() {
@Override

View File

@ -179,18 +179,10 @@ public class ELBAsyncClientTest extends RestClientTest<ELBAsyncClient> {
protected String provider = "elb";
@Override
protected Properties getProperties() {
Properties overrides = new Properties();
overrides.setProperty(provider + ".endpoint", "https://elasticloadbalancing.us-east-1.amazonaws.com");
overrides.setProperty(provider + ".propertiesbuilder", ELBPropertiesBuilder.class.getName());
overrides.setProperty(provider + ".contextbuilder", ELBContextBuilder.class.getName());
return overrides;
}
@Override
public RestContextSpec<?, ?> createContextSpec() {
return new RestContextFactory(getProperties()).createContextSpec(provider, "identity", "credential",
return new RestContextFactory(setupRestProperties()).createContextSpec(provider, "identity", "credential",
new Properties());
}

View File

@ -24,12 +24,12 @@ import static org.testng.Assert.assertNotNull;
import java.util.Properties;
import java.util.Set;
import org.jclouds.Constants;
import org.jclouds.elb.domain.LoadBalancer;
import org.jclouds.loadbalancer.LoadBalancerServiceContextFactory;
import org.jclouds.logging.log4j.config.Log4JLoggingModule;
import org.jclouds.rest.BaseRestClientLiveTest;
import org.jclouds.rest.RestContext;
import org.testng.annotations.AfterTest;
import org.testng.annotations.AfterGroups;
import org.testng.annotations.BeforeGroups;
import org.testng.annotations.Test;
@ -41,53 +41,31 @@ import com.google.inject.Module;
*
* @author Lili Nader
*/
@Test(groups = "live", sequential = true)
public class ELBClientLiveTest {
@Test(groups = "live", singleThreaded = true, testName = "ELBClientLiveTest")
public class ELBClientLiveTest extends BaseRestClientLiveTest {
public ELBClientLiveTest() {
provider = "elb";
}
private ELBClient client;
private RestContext<ELBClient, ELBAsyncClient> context;
protected String provider = "elb";
protected String identity;
protected String credential;
protected String endpoint;
protected String apiVersion;
protected String name = "TestLoadBalancer";
protected void setupCredentials() {
identity = checkNotNull(System.getProperty("test." + provider + ".identity"), "test." + provider + ".identity");
credential = checkNotNull(System.getProperty("test." + provider + ".credential"), "test." + provider
+ ".credential");
endpoint = System.getProperty("test." + provider + ".endpoint");
apiVersion = System.getProperty("test." + provider + ".api-version");
}
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 + ".api-version", apiVersion);
return overrides;
}
@BeforeGroups(groups = { "live" })
@BeforeGroups(groups = "live")
public void setupClient() {
setupCredentials();
Properties overrides = setupProperties();
context = new LoadBalancerServiceContextFactory().createContext(provider,
ImmutableSet.<Module> of(new Log4JLoggingModule()), overrides).getProviderSpecificContext();
ImmutableSet.<Module> of(new Log4JLoggingModule()), overrides).getProviderSpecificContext();
client = context.getApi();
}
@Test
public void testCreateLoadBalancer() {
createLoadBalancerInRegionZone(null,
checkNotNull(System.getProperty("test." + provider + ".zone"), "test." + provider + ".zone"), name);
createLoadBalancerInRegionZone(null, checkNotNull(System.getProperty("test." + provider + ".zone"), "test."
+ provider + ".zone"), name);
}
protected void createLoadBalancerInRegionZone(String region, String zone, String name) {
@ -107,7 +85,7 @@ public class ELBClientLiveTest {
assert (allResults.size() >= 1) : region;
}
@Test
@Test(dependsOnMethods = "testDescribeLoadBalancers")
public void testDeleteLoadBalancer() {
deleteLoadBalancerInRegion(null);
}
@ -116,8 +94,12 @@ public class ELBClientLiveTest {
client.deleteLoadBalancerInRegion(region, name);
}
@AfterTest
@AfterGroups(groups = "live")
public void shutdown() {
context.close();
try {
testDeleteLoadBalancer();
} finally {
context.close();
}
}
}

View File

@ -37,7 +37,7 @@ import org.testng.annotations.Test;
*
* @author Lili Nadar
*/
@Test(groups = "live", sequential = true)
@Test(groups = "live", singleThreaded = true, testName = "ELBLoadBalancerServiceLiveTest")
public class ELBLoadBalancerServiceLiveTest extends BaseLoadBalancerServiceLiveTest {
public ELBLoadBalancerServiceLiveTest() {

Some files were not shown because too many files have changed in this diff Show More