mirror of https://github.com/apache/jclouds.git
Issue 550: updated aws provider metadata
This commit is contained in:
parent
c880c057b1
commit
f70b793533
|
@ -32,8 +32,7 @@ import java.util.ServiceLoader;
|
|||
public class Providers {
|
||||
|
||||
/**
|
||||
* Returns the providers located on the classpath via
|
||||
* {@link java.util.ServiceLoader}.
|
||||
* Returns the providers located on the classpath via {@link java.util.ServiceLoader}.
|
||||
*
|
||||
* @return all available providers loaded from classpath via ServiceLoader
|
||||
*/
|
||||
|
@ -59,10 +58,9 @@ public class Providers {
|
|||
* @return the provider with the given id
|
||||
*
|
||||
* @throws NoSuchElementException
|
||||
* whenever there are no providers with the provided id
|
||||
* whenever there are no providers with the provided id
|
||||
*/
|
||||
public static ProviderMetadata withId(String id)
|
||||
throws NoSuchElementException {
|
||||
public static ProviderMetadata withId(String id) throws NoSuchElementException {
|
||||
return find(all(), ProviderPredicates.id(id));
|
||||
}
|
||||
|
||||
|
@ -86,6 +84,36 @@ public class Providers {
|
|||
return filter(all(), ProviderPredicates.type(ProviderMetadata.COMPUTE_TYPE));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the providers that are of type
|
||||
* {@link org.jclouds.providers.ProviderMetadata#QUEUE_TYPE}.
|
||||
*
|
||||
* @return the queue service providers
|
||||
*/
|
||||
public static Iterable<ProviderMetadata> allQueue() {
|
||||
return filter(all(), ProviderPredicates.type(ProviderMetadata.QUEUE_TYPE));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the providers that are of type
|
||||
* {@link org.jclouds.providers.ProviderMetadata#TABLE_TYPE}.
|
||||
*
|
||||
* @return the table service providers
|
||||
*/
|
||||
public static Iterable<ProviderMetadata> allTable() {
|
||||
return filter(all(), ProviderPredicates.type(ProviderMetadata.TABLE_TYPE));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the providers that are of type
|
||||
* {@link org.jclouds.providers.ProviderMetadata#LOADBALANCER_TYPE}.
|
||||
*
|
||||
* @return the load balancer service providers
|
||||
*/
|
||||
public static Iterable<ProviderMetadata> allLoadBalancer() {
|
||||
return filter(all(), ProviderPredicates.type(ProviderMetadata.LOADBALANCER_TYPE));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the providers that are of the provided type.
|
||||
*
|
||||
|
|
|
@ -26,7 +26,6 @@ import org.testng.annotations.Test;
|
|||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -36,6 +35,7 @@ import com.google.common.collect.Sets;
|
|||
public abstract class BaseProviderMetadataTest {
|
||||
protected Set<String> allTypes = ImmutableSet.of(ProviderMetadata.BLOBSTORE_TYPE, ProviderMetadata.COMPUTE_TYPE,
|
||||
ProviderMetadata.LOADBALANCER_TYPE, ProviderMetadata.QUEUE_TYPE, ProviderMetadata.TABLE_TYPE);
|
||||
|
||||
private final ProviderMetadata toTest;
|
||||
private final String expectedType;
|
||||
|
||||
|
@ -52,21 +52,15 @@ public abstract class BaseProviderMetadataTest {
|
|||
assert providerMetadata.getLinkedServices().contains(toTest.getId());
|
||||
}
|
||||
|
||||
// it is ok to have multiple services in the same classpath (ex. ec2 vs elb)
|
||||
@Test
|
||||
public void testOfType() {
|
||||
assertEquals(Iterables.getOnlyElement(Providers.ofType(expectedType)), toTest);
|
||||
|
||||
for (String type : Sets.difference(allTypes, ImmutableSet.of(expectedType)))
|
||||
assertEquals(Iterables.size(Providers.ofType(type)), 0);
|
||||
public void testOfTypeContains() {
|
||||
assert ImmutableSet.of(Providers.ofType(expectedType)).contains(toTest);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAll() {
|
||||
Iterable<ProviderMetadata> providersMetadata = Providers.all();
|
||||
|
||||
for (ProviderMetadata providerMetadata : providersMetadata) {
|
||||
assertEquals(toTest, providerMetadata);
|
||||
}
|
||||
public void testAllContains() {
|
||||
assert ImmutableSet.of(Providers.all()).contains(toTest);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -63,7 +63,7 @@ public class AWSEC2ProviderMetadata extends BaseProviderMetadata {
|
|||
*/
|
||||
@Override
|
||||
public String getIdentityName() {
|
||||
return "accessKeyID";
|
||||
return "Access Key ID";
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -71,7 +71,7 @@ public class AWSEC2ProviderMetadata extends BaseProviderMetadata {
|
|||
*/
|
||||
@Override
|
||||
public String getCredentialName() {
|
||||
return "secretAccessKey";
|
||||
return "Secret Access Key";
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -102,7 +102,7 @@ public class AWSEC2ProviderMetadata extends BaseProviderMetadata {
|
|||
*/
|
||||
@Override
|
||||
public Set<String> getLinkedServices() {
|
||||
return ImmutableSet.of(getId(), "aws-s3");
|
||||
return ImmutableSet.of("aws-s3", "aws-ec2", "aws-elb", "aws-simpledb");
|
||||
}
|
||||
|
||||
}
|
|
@ -55,7 +55,7 @@ public class AWSS3ProviderMetadata extends BaseProviderMetadata {
|
|||
*/
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Amazon Elastic Compute Cloud (S3)";
|
||||
return "Amazon Simple Storage Service (S3)";
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -63,7 +63,7 @@ public class AWSS3ProviderMetadata extends BaseProviderMetadata {
|
|||
*/
|
||||
@Override
|
||||
public String getIdentityName() {
|
||||
return "accessKeyID";
|
||||
return "Access Key ID";
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -71,7 +71,7 @@ public class AWSS3ProviderMetadata extends BaseProviderMetadata {
|
|||
*/
|
||||
@Override
|
||||
public String getCredentialName() {
|
||||
return "secretAccessKey";
|
||||
return "Secret Access Key";
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -0,0 +1,108 @@
|
|||
/**
|
||||
*
|
||||
* 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.aws.elb;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.Set;
|
||||
|
||||
import org.jclouds.providers.BaseProviderMetadata;
|
||||
import org.jclouds.providers.ProviderMetadata;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
/**
|
||||
* Implementation of @ link org.jclouds.types.ProviderMetadata} for Amazon's Elastic Load Balancing
|
||||
* provider.
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class AWSELBProviderMetadata extends BaseProviderMetadata {
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String getId() {
|
||||
return "aws-elb";
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String getType() {
|
||||
return ProviderMetadata.LOADBALANCER_TYPE;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Amazon Elastic Load Balancing";
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String getIdentityName() {
|
||||
return "Access Key ID";
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String getCredentialName() {
|
||||
return "Secret Access Key";
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public URI getHomepage() {
|
||||
return URI.create("http://aws.amazon.com/elasticloadbalancing");
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public URI getConsole() {
|
||||
return URI.create("https://console.aws.amazon.com/ec2/home");
|
||||
}
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public URI getApiDocumentation() {
|
||||
return URI.create("http://docs.amazonwebservices.com/ElasticLoadBalancing/latest/APIReference");
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Set<String> getLinkedServices() {
|
||||
return ImmutableSet.of("aws-s3", "aws-ec2", "aws-elb", "aws-simpledb");
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
org.jclouds.aws.elb.AWSELBProviderMetadata
|
|
@ -18,23 +18,19 @@
|
|||
*/
|
||||
package org.jclouds.aws.elb;
|
||||
|
||||
import org.jclouds.rest.Providers;
|
||||
import org.jclouds.providers.BaseProviderMetadataTest;
|
||||
import org.jclouds.providers.ProviderMetadata;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.Iterables;
|
||||
|
||||
/**
|
||||
* The AWSELBProviderTest tests the org.jclouds.providers.AWSELBProvider class.
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*
|
||||
*/
|
||||
@Test(groups = "unit")
|
||||
public class ProvidersInPropertiesTest {
|
||||
@Test(groups = "unit", testName = "AWSELBProviderTest")
|
||||
public class AWSELBProviderTest extends BaseProviderMetadataTest {
|
||||
|
||||
@Test
|
||||
public void testSupportedProviders() {
|
||||
Iterable<String> providers = Providers.getSupportedProviders();
|
||||
assert Iterables.contains(providers, "aws-elb") : providers;
|
||||
public AWSELBProviderTest() {
|
||||
super(new AWSELBProviderMetadata(), ProviderMetadata.LOADBALANCER_TYPE);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,108 @@
|
|||
/**
|
||||
*
|
||||
* 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.aws.simpledb;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.Set;
|
||||
|
||||
import org.jclouds.providers.BaseProviderMetadata;
|
||||
import org.jclouds.providers.ProviderMetadata;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
/**
|
||||
* Implementation of @ link org.jclouds.types.ProviderMetadata} for Amazon's SimpleDB provider.
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class AWSSimpleDBProviderMetadata extends BaseProviderMetadata {
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String getId() {
|
||||
return "aws-simpledb";
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String getType() {
|
||||
return ProviderMetadata.TABLE_TYPE;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Amazon SimpleDB";
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String getIdentityName() {
|
||||
return "Access Key ID";
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String getCredentialName() {
|
||||
return "Secret Access Key";
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public URI getHomepage() {
|
||||
return URI.create("http://aws.amazon.com/simpledb");
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public URI getConsole() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public URI getApiDocumentation() {
|
||||
return URI.create("http://docs.amazonwebservices.com/AmazonSimpleDB/latest/DeveloperGuide");
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Set<String> getLinkedServices() {
|
||||
return ImmutableSet.of("aws-s3", "aws-ec2", "aws-elb", "aws-simpledb");
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
org.jclouds.aws.simpledb.AWSSimpleDBProviderMetadata
|
|
@ -0,0 +1,36 @@
|
|||
/**
|
||||
*
|
||||
* 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.aws.simpledb;
|
||||
|
||||
import org.jclouds.providers.BaseProviderMetadataTest;
|
||||
import org.jclouds.providers.ProviderMetadata;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
/**
|
||||
* The AWSSimpleDBProviderTest tests the org.jclouds.providers.AWSSimpleDBProvider class.
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@Test(groups = "unit", testName = "AWSSimpleDBProviderTest")
|
||||
public class AWSSimpleDBProviderTest extends BaseProviderMetadataTest {
|
||||
|
||||
public AWSSimpleDBProviderTest() {
|
||||
super(new AWSSimpleDBProviderMetadata(), ProviderMetadata.TABLE_TYPE);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue