Issue 334: added aws-cloudwatch provider

This commit is contained in:
Adrian Cole 2011-09-16 15:36:29 -07:00
parent 8a229dc88a
commit e766248327
28 changed files with 435 additions and 14 deletions

View File

@ -39,6 +39,8 @@ our loadbalancer api supports: cloudloadbalancers-us
* note * the pom dependency org.jclouds/jclouds-allloadbalancer gives you access to
to all of these providers
we also have aws-cloudwatch support.
we also have support for: ibmdev, mezeo, nirvanix, boxdotnet, openstack nova, scality ring,
hosteurope-storage, tiscali-storage, scaleup-storage, googlestorage,
azurequeue, simpledb, cloudstack as well as a async-http-client

View File

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

View File

@ -0,0 +1,53 @@
/**
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds licenses this file
* to you 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.cloudwatch;
import static org.jclouds.Constants.PROPERTY_API_VERSION;
import static org.jclouds.aws.reference.AWSConstants.PROPERTY_AUTH_TAG;
import static org.jclouds.aws.reference.AWSConstants.PROPERTY_HEADER_TAG;
import java.util.Properties;
import org.jclouds.PropertiesBuilder;
/**
* Builds properties used in Cloud Watch Clients
*
* @author Adrian Cole
*/
public class CloudWatchPropertiesBuilder extends PropertiesBuilder {
@Override
protected Properties defaultProperties() {
Properties properties = super.defaultProperties();
properties.setProperty(PROPERTY_AUTH_TAG, "AWS");
properties.setProperty(PROPERTY_HEADER_TAG, "amz");
properties.setProperty(PROPERTY_API_VERSION, CloudWatchAsyncClient.VERSION);
return properties;
}
public CloudWatchPropertiesBuilder() {
super();
}
public CloudWatchPropertiesBuilder(Properties properties) {
super(properties);
}
}

View File

@ -109,7 +109,9 @@ public class CloudWatchAsyncClientTest extends RestClientTest<CloudWatchAsyncCli
@Override
public RestContextSpec<?, ?> createContextSpec() {
return new RestContextFactory().createContextSpec("cloudwatch", "identity", "credential", new Properties());
Properties props = new Properties();
props.setProperty("cloudwatch.endpoint", "https://monitoring.us-east-1.amazonaws.com");
return new RestContextFactory().createContextSpec("cloudwatch", "identity", "credential", props);
}
@Override

View File

@ -25,7 +25,6 @@ import java.util.Date;
import java.util.Properties;
import org.jclouds.Constants;
import org.jclouds.aws.domain.Region;
import org.jclouds.logging.log4j.config.Log4JLoggingModule;
import org.jclouds.rest.RestContext;
import org.jclouds.rest.RestContextFactory;
@ -55,7 +54,7 @@ public class CloudWatchClientLiveTest {
protected void setupCredentials() {
identity = checkNotNull(System.getProperty("test." + provider + ".identity"), "test." + provider + ".identity");
credential = checkNotNull(System.getProperty("test." + provider + ".credential"), "test." + provider
+ ".credential");
+ ".credential");
endpoint = System.getProperty("test." + provider + ".endpoint", null);
apiversion = System.getProperty("test." + provider + ".apiversion", null);
}
@ -78,17 +77,19 @@ public class CloudWatchClientLiveTest {
setupCredentials();
Properties overrides = setupProperties();
context = new RestContextFactory().createContext(provider, ImmutableSet.<Module> of(new Log4JLoggingModule()),
overrides);
overrides);
client = context.getApi();
}
@Test
void testGetMetricStatisticsInRegion() {
protected void testGetMetricStatisticsInRegion() {
getMetricStatisticsInRegion(null);
}
protected void getMetricStatisticsInRegion(String region) {
Calendar cal = Calendar.getInstance();
cal.add(Calendar.MINUTE, -1);
for (String region : Region.DEFAULT_REGIONS) {
assert client.getMetricStatisticsInRegion(region, "CPUUtilization", cal.getTime(), new Date(), 60, "Average") != null;
}
assert client.getMetricStatisticsInRegion(region, "CPUUtilization", cal.getTime(), new Date(), 60, "Average") != null;
}
@AfterTest

View File

@ -46,5 +46,6 @@
<module>elasticstack</module>
<module>atmos</module>
<module>nova</module>
<module>cloudwatch</module>
</modules>
</project>

View File

@ -36,6 +36,7 @@ public interface ProviderMetadata {
public static final String LOADBALANCER_TYPE = "loadbalancer";
public static final String TABLE_TYPE = "table";
public static final String QUEUE_TYPE = "queue";
public static final String MONITOR_TYPE = "monitor";
/**
*

View File

@ -29,6 +29,9 @@ aws-elb.propertiesbuilder=org.jclouds.aws.elb.AWSELBPropertiesBuilder
cloudwatch.contextbuilder=org.jclouds.cloudwatch.CloudWatchContextBuilder
cloudwatch.propertiesbuilder=org.jclouds.cloudwatch.CloudWatchPropertiesBuilder
aws-cloudwatch.contextbuilder=org.jclouds.cloudwatch.CloudWatchContextBuilder
aws-cloudwatch.propertiesbuilder=org.jclouds.aws.cloudwatch.AWSCloudWatchPropertiesBuilder
aws-s3.contextbuilder=org.jclouds.aws.s3.AWSS3ContextBuilder
aws-s3.propertiesbuilder=org.jclouds.aws.s3.AWSS3PropertiesBuilder

View File

@ -0,0 +1,157 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to jclouds, Inc. (jclouds) under one or more
contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. jclouds licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.jclouds</groupId>
<artifactId>jclouds-project</artifactId>
<version>1.2.0-SNAPSHOT</version>
<relativePath>../../project/pom.xml</relativePath>
</parent>
<groupId>org.jclouds.provider</groupId>
<artifactId>aws-cloudwatch</artifactId>
<name>jclouds Amazon Elastic Load Balancer provider</name>
<description>Elastic Load Balancer implementation targeted to Amazon Web Services</description>
<packaging>bundle</packaging>
<properties>
<test.aws-cloudwatch.endpoint>https://monitoring.us-east-1.amazonaws.com</test.aws-cloudwatch.endpoint>
<test.aws-cloudwatch.apiversion>2009-05-15</test.aws-cloudwatch.apiversion>
<test.aws-cloudwatch.identity>${test.aws.identity}</test.aws-cloudwatch.identity>
<test.aws-cloudwatch.credential>${test.aws.credential}</test.aws-cloudwatch.credential>
</properties>
<dependencies>
<dependency>
<groupId>org.jclouds.api</groupId>
<artifactId>cloudwatch</artifactId>
<version>${project.version}</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>org.jclouds.api</groupId>
<artifactId>cloudwatch</artifactId>
<version>${project.version}</version>
<type>test-jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jclouds</groupId>
<artifactId>jclouds-core</artifactId>
<version>${project.version}</version>
<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-log4j</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
<profiles>
<profile>
<id>live</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<executions>
<execution>
<id>integration</id>
<phase>integration-test</phase>
<goals>
<goal>test</goal>
</goals>
<configuration>
<systemProperties>
<property>
<name>test.aws-cloudwatch.endpoint</name>
<value>${test.aws-cloudwatch.endpoint}</value>
</property>
<property>
<name>test.aws-cloudwatch.apiversion</name>
<value>${test.aws-cloudwatch.apiversion}</value>
</property>
<property>
<name>test.aws-cloudwatch.identity</name>
<value>${test.aws-cloudwatch.identity}</value>
</property>
<property>
<name>test.aws-cloudwatch.credential</name>
<value>${test.aws-cloudwatch.credential}</value>
</property>
<property>
<name>test.aws-cloudwatch.compute.provider</name>
<value>${test.aws-cloudwatch.compute.provider}</value>
</property>
<property>
<name>test.aws-cloudwatch.compute.endpoint</name>
<value>${test.aws-cloudwatch.compute.endpoint}</value>
</property>
<property>
<name>test.aws-cloudwatch.compute.apiversion</name>
<value>${test.aws-cloudwatch.compute.apiversion}</value>
</property>
<property>
<name>test.aws-cloudwatch.compute.identity</name>
<value>${test.aws-cloudwatch.compute.identity}</value>
</property>
<property>
<name>test.aws-cloudwatch.compute.credential</name>
<value>${test.aws-cloudwatch.compute.credential}</value>
</property>
</systemProperties>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
<build>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<configuration>
<instructions>
<Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
<Export-Package>org.jclouds.aws.cloudwatch.*;version="${project.version}"</Export-Package>
<Import-Package>org.jclouds.*;version="${project.version}",*</Import-Package>
</instructions>
</configuration>
</plugin>
</plugins>
</build>
</project>

View File

@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
package org.jclouds.cloudwatch;
package org.jclouds.aws.cloudwatch;
import static org.jclouds.Constants.PROPERTY_API_VERSION;
import static org.jclouds.Constants.PROPERTY_ENDPOINT;
@ -26,15 +26,16 @@ import static org.jclouds.location.reference.LocationConstants.PROPERTY_REGION;
import java.util.Properties;
import org.jclouds.PropertiesBuilder;
import org.jclouds.aws.domain.Region;
import org.jclouds.cloudwatch.CloudWatchAsyncClient;
import org.jclouds.cloudwatch.CloudWatchPropertiesBuilder;
/**
* Builds properties used in Cloud Watch Clients
* Builds properties used in CloudWatch Clients
*
* @author Adrian Cole
*/
public class CloudWatchPropertiesBuilder extends PropertiesBuilder {
public class AWSCloudWatchPropertiesBuilder extends CloudWatchPropertiesBuilder {
@Override
protected Properties defaultProperties() {
@ -57,11 +58,11 @@ public class CloudWatchPropertiesBuilder extends PropertiesBuilder {
return properties;
}
public CloudWatchPropertiesBuilder() {
public AWSCloudWatchPropertiesBuilder() {
super();
}
public CloudWatchPropertiesBuilder(Properties properties) {
public AWSCloudWatchPropertiesBuilder(Properties properties) {
super(properties);
}

View File

@ -0,0 +1,115 @@
/**
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds licenses this file
* to you 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.cloudwatch;
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 CloudWatch
* provider.
*
* @author Adrian Cole
*/
public class AWSCloudWatchProviderMetadata extends BaseProviderMetadata {
/**
* {@inheritDoc}
*/
@Override
public String getId() {
return "aws-cloudwatch";
}
/**
* {@inheritDoc}
*/
@Override
public String getType() {
return ProviderMetadata.MONITOR_TYPE;
}
/**
* {@inheritDoc}
*/
@Override
public String getName() {
return "Amazon CloudWatch";
}
/**
* {@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/cloudwatch");
}
/**
* {@inheritDoc}
*/
@Override
public URI getConsole() {
return URI.create("https://console.aws.amazon.com/cloudwatch/home");
}
/**
* {@inheritDoc}
*/
@Override
public URI getApiDocumentation() {
return URI.create("http://docs.amazonwebservices.com/AmazonCloudWatch/latest/APIReference/");
}
/**
* {@inheritDoc}
*/
@Override
public Set<String> getLinkedServices() {
return ImmutableSet.of("aws-s3", "aws-ec2", "aws-cloudwatch", "aws-simpledb");
}
/**
* {@inheritDoc}
*/
@Override
public Set<String> getIso3166Codes() {
return ImmutableSet.of("US-VA", "US-CA", "IE", "SG", "JP-13");
}
}

View File

@ -0,0 +1 @@
org.jclouds.aws.cloudwatch.AWSCloudWatchProviderMetadata

View File

@ -0,0 +1,42 @@
/**
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds licenses this file
* to you 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.cloudwatch;
import org.jclouds.aws.domain.Region;
import org.jclouds.cloudwatch.CloudWatchClientLiveTest;
import org.testng.annotations.Test;
/**
* Tests behavior of {@code CloudWatchClient}
*
* @author Adrian Cole
*/
@Test(groups = "live", singleThreaded = true, testName = "AWSCloudWatchClientLiveTest")
public class AWSCloudWatchClientLiveTest extends CloudWatchClientLiveTest {
public AWSCloudWatchClientLiveTest() {
provider = "aws-cloudwatch";
}
@Test
public void testGetMetricStatisticsInRegion() {
for (String region : Region.DEFAULT_REGIONS) {
getMetricStatisticsInRegion(region);
}
}
}

View File

@ -0,0 +1,36 @@
/**
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds licenses this file
* to you 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.cloudwatch;
import org.jclouds.providers.BaseProviderMetadataTest;
import org.jclouds.providers.ProviderMetadata;
import org.testng.annotations.Test;
/**
* The AWSCloudWatchProviderTest tests the org.jclouds.providers.AWSCloudWatchProvider class.
*
* @author Adrian Cole
*/
@Test(groups = "unit", testName = "AWSCloudWatchProviderTest")
public class AWSCloudWatchProviderTest extends BaseProviderMetadataTest {
public AWSCloudWatchProviderTest() {
super(new AWSCloudWatchProviderMetadata(), ProviderMetadata.MONITOR_TYPE);
}
}

View File

@ -62,5 +62,6 @@
<module>skalicloud-sdg-my</module>
<module>savvis-symphonyvpdc</module>
<module>greenhousedata-element-vcloud</module>
<module>aws-cloudwatch</module>
</modules>
</project>