mirror of https://github.com/apache/jclouds.git
Merge branch 'master' of git://github.com/jclouds/jclouds
This commit is contained in:
commit
e7dce95ace
|
@ -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
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -21,7 +21,6 @@ package org.jclouds.cloudwatch;
|
|||
import java.util.Date;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import javax.ws.rs.FormParam;
|
||||
import javax.ws.rs.POST;
|
||||
import javax.ws.rs.Path;
|
||||
|
@ -30,6 +29,7 @@ import org.jclouds.aws.filters.FormSigner;
|
|||
import org.jclouds.cloudwatch.domain.Datapoint;
|
||||
import org.jclouds.cloudwatch.functions.ISO8601Format;
|
||||
import org.jclouds.cloudwatch.xml.GetMetricStatisticsResponseHandler;
|
||||
import org.jclouds.javax.annotation.Nullable;
|
||||
import org.jclouds.location.functions.RegionToEndpointOrProviderIfNull;
|
||||
import org.jclouds.rest.annotations.EndpointParam;
|
||||
import org.jclouds.rest.annotations.FormParams;
|
|
@ -22,10 +22,9 @@ import java.util.Date;
|
|||
import java.util.Set;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import org.jclouds.cloudwatch.domain.Datapoint;
|
||||
import org.jclouds.concurrent.Timeout;
|
||||
import org.jclouds.javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* Provides access to Amazon CloudWatch via the Query API
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
|
@ -20,7 +20,7 @@ package org.jclouds.cloudwatch.domain;
|
|||
|
||||
import java.util.Date;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import org.jclouds.javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* @see <a href="http://docs.amazonwebservices.com/AmazonCloudWatch/latest/DeveloperGuide/index.html?DT_Datapoint.html"
|
|
@ -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
|
|
@ -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
|
|
@ -46,5 +46,6 @@
|
|||
<module>elasticstack</module>
|
||||
<module>atmos</module>
|
||||
<module>nova</module>
|
||||
<module>cloudwatch</module>
|
||||
</modules>
|
||||
</project>
|
||||
|
|
|
@ -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";
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -0,0 +1,151 @@
|
|||
<?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.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>
|
|
@ -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);
|
||||
}
|
||||
|
|
@ -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");
|
||||
}
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
org.jclouds.aws.cloudwatch.AWSCloudWatchProviderMetadata
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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);
|
||||
}
|
||||
}
|
|
@ -58,6 +58,12 @@
|
|||
<type>test-jar</type>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jclouds.provider</groupId>
|
||||
<artifactId>aws-cloudwatch</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jclouds</groupId>
|
||||
<artifactId>jclouds-core</artifactId>
|
||||
|
|
|
@ -20,12 +20,16 @@ package org.jclouds.aws.ec2.compute;
|
|||
|
||||
import static org.testng.Assert.assertEquals;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.Set;
|
||||
|
||||
import org.jclouds.aws.ec2.AWSEC2Client;
|
||||
import org.jclouds.aws.ec2.domain.AWSRunningInstance;
|
||||
import org.jclouds.aws.ec2.domain.MonitoringState;
|
||||
import org.jclouds.aws.ec2.services.AWSSecurityGroupClient;
|
||||
import org.jclouds.cloudwatch.CloudWatchAsyncClient;
|
||||
import org.jclouds.cloudwatch.CloudWatchClient;
|
||||
import org.jclouds.cloudwatch.domain.Datapoint;
|
||||
import org.jclouds.compute.domain.NodeMetadata;
|
||||
import org.jclouds.compute.options.TemplateOptions;
|
||||
import org.jclouds.compute.predicates.NodePredicates;
|
||||
|
@ -38,12 +42,17 @@ import org.jclouds.ec2.domain.SecurityGroup;
|
|||
import org.jclouds.ec2.services.InstanceClient;
|
||||
import org.jclouds.ec2.services.KeyPairClient;
|
||||
import org.jclouds.ec2.util.IpPermissions;
|
||||
import org.jclouds.logging.log4j.config.Log4JLoggingModule;
|
||||
import org.jclouds.rest.RestContext;
|
||||
import org.jclouds.rest.RestContextFactory;
|
||||
import org.jclouds.scriptbuilder.domain.Statements;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.ImmutableSortedSet;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.Sets;
|
||||
import com.google.inject.Module;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -73,7 +82,7 @@ public class AWSEC2ComputeServiceLiveTest extends EC2ComputeServiceLiveTest {
|
|||
|
||||
TemplateOptions options = client.templateOptions();
|
||||
|
||||
// Date before = new Date();
|
||||
Date before = new Date();
|
||||
|
||||
options.as(AWSEC2TemplateOptions.class).enableMonitoring();
|
||||
options.as(AWSEC2TemplateOptions.class).spotPrice(0.3f);
|
||||
|
@ -114,20 +123,17 @@ public class AWSEC2ComputeServiceLiveTest extends EC2ComputeServiceLiveTest {
|
|||
assertEquals(instance.getKeyName(), group);
|
||||
assertEquals(instance.getMonitoringState(), MonitoringState.ENABLED);
|
||||
|
||||
// TODO when the cloudwatchclient is finished
|
||||
|
||||
// RestContext<CloudWatchClient, CloudWatchAsyncClient> monitoringContext = new
|
||||
// RestContextFactory().createContext(
|
||||
// "cloudwatch", identity, credential, ImmutableSet.<Module> of(new Log4JLoggingModule()));
|
||||
//
|
||||
// try {
|
||||
// Set<Datapoint> datapoints =
|
||||
// monitoringContext.getApi().getMetricStatisticsInRegion(instance.getRegion(),
|
||||
// "CPUUtilization", before, new Date(), 60, "Average");
|
||||
// assert datapoints != null;
|
||||
// } finally {
|
||||
// monitoringContext.close();
|
||||
// }
|
||||
RestContext<CloudWatchClient, CloudWatchAsyncClient> monitoringContext = new RestContextFactory()
|
||||
.createContext("aws-cloudwatch", identity, credential, ImmutableSet.<Module> of(new Log4JLoggingModule()));
|
||||
|
||||
try {
|
||||
Set<Datapoint> datapoints = monitoringContext.getApi().getMetricStatisticsInRegion(instance.getRegion(),
|
||||
"CPUUtilization", before, new Date(), 60, "Average");
|
||||
assert datapoints != null;
|
||||
} finally {
|
||||
monitoringContext.close();
|
||||
}
|
||||
|
||||
// make sure we made our dummy group and also let in the user's group
|
||||
assertEquals(Sets.newTreeSet(instance.getGroupIds()), ImmutableSortedSet.<String> of("jclouds#" + group + "#"
|
||||
|
|
|
@ -62,5 +62,6 @@
|
|||
<module>skalicloud-sdg-my</module>
|
||||
<module>savvis-symphonyvpdc</module>
|
||||
<module>greenhousedata-element-vcloud</module>
|
||||
<module>aws-cloudwatch</module>
|
||||
</modules>
|
||||
</project>
|
||||
|
|
|
@ -56,7 +56,7 @@
|
|||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.jclouds</groupId>
|
||||
<artifactId>jclouds-core</artifactId>
|
||||
<artifactId>jclouds-compute</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
@ -67,9 +67,10 @@
|
|||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>log4j</groupId>
|
||||
<artifactId>log4j</artifactId>
|
||||
<version>1.2.16</version>
|
||||
<groupId>org.jclouds</groupId>
|
||||
<artifactId>jclouds-compute</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<type>test-jar</type>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
@ -78,6 +79,12 @@
|
|||
<version>${project.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jclouds.driver</groupId>
|
||||
<artifactId>jclouds-sshj</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<profiles>
|
||||
<profile>
|
||||
|
|
|
@ -21,7 +21,8 @@ package org.jclouds.softlayer;
|
|||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.jclouds.rest.RestContextBuilder;
|
||||
import org.jclouds.compute.ComputeServiceContextBuilder;
|
||||
import org.jclouds.softlayer.compute.config.SoftLayerComputeServiceContextModule;
|
||||
import org.jclouds.softlayer.config.SoftLayerRestClientModule;
|
||||
|
||||
import com.google.inject.Module;
|
||||
|
@ -30,13 +31,18 @@ import com.google.inject.Module;
|
|||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class SoftLayerContextBuilder extends
|
||||
RestContextBuilder<SoftLayerClient, SoftLayerAsyncClient> {
|
||||
public class SoftLayerContextBuilder extends ComputeServiceContextBuilder<SoftLayerClient, SoftLayerAsyncClient> {
|
||||
|
||||
public SoftLayerContextBuilder(Properties props) {
|
||||
super(SoftLayerClient.class, SoftLayerAsyncClient.class, props);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addContextModule(List<Module> modules) {
|
||||
modules.add(new SoftLayerComputeServiceContextModule());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addClientModule(List<Module> modules) {
|
||||
modules.add(new SoftLayerRestClientModule());
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@ import static org.jclouds.Constants.PROPERTY_ENDPOINT;
|
|||
import java.util.Properties;
|
||||
|
||||
import org.jclouds.PropertiesBuilder;
|
||||
import org.jclouds.softlayer.reference.SoftLayerConstants;
|
||||
|
||||
/**
|
||||
* Builds properties used in SoftLayer Clients
|
||||
|
@ -36,6 +37,7 @@ public class SoftLayerPropertiesBuilder extends PropertiesBuilder {
|
|||
Properties properties = super.defaultProperties();
|
||||
properties.setProperty(PROPERTY_ENDPOINT, "https://api.softlayer.com/rest");
|
||||
properties.setProperty(PROPERTY_API_VERSION, "3");
|
||||
properties.setProperty(SoftLayerConstants.PROPERTY_SOFTLAYER_VIRTUALGUEST_PACKAGE_NAME, "Cloud Server");
|
||||
return properties;
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,70 @@
|
|||
/**
|
||||
* 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.softlayer.compute.config;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import org.jclouds.compute.ComputeServiceAdapter;
|
||||
import org.jclouds.compute.config.ComputeServiceAdapterContextModule;
|
||||
import org.jclouds.compute.domain.NodeMetadata;
|
||||
import org.jclouds.domain.Location;
|
||||
import org.jclouds.location.suppliers.OnlyLocationOrFirstZone;
|
||||
import org.jclouds.softlayer.SoftLayerAsyncClient;
|
||||
import org.jclouds.softlayer.SoftLayerClient;
|
||||
import org.jclouds.softlayer.compute.functions.DatacenterToLocation;
|
||||
import org.jclouds.softlayer.compute.functions.ProductItemPriceToImage;
|
||||
import org.jclouds.softlayer.compute.functions.ProductItemPricesToHardware;
|
||||
import org.jclouds.softlayer.compute.functions.VirtualGuestToNodeMetadata;
|
||||
import org.jclouds.softlayer.compute.strategy.SoftLayerComputeServiceAdapter;
|
||||
import org.jclouds.softlayer.domain.Datacenter;
|
||||
import org.jclouds.softlayer.domain.ProductItemPrice;
|
||||
import org.jclouds.softlayer.domain.VirtualGuest;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.base.Supplier;
|
||||
import com.google.inject.TypeLiteral;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class SoftLayerComputeServiceContextModule extends
|
||||
ComputeServiceAdapterContextModule<SoftLayerClient, SoftLayerAsyncClient, VirtualGuest, Set<ProductItemPrice>, ProductItemPrice, Datacenter> {
|
||||
|
||||
public SoftLayerComputeServiceContextModule() {
|
||||
super(SoftLayerClient.class, SoftLayerAsyncClient.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void configure() {
|
||||
super.configure();
|
||||
bind(new TypeLiteral<ComputeServiceAdapter<VirtualGuest, Set<ProductItemPrice>, ProductItemPrice, Datacenter>>() {
|
||||
}).to(SoftLayerComputeServiceAdapter.class);
|
||||
bind(new TypeLiteral<Function<VirtualGuest, NodeMetadata>>() {
|
||||
}).to(VirtualGuestToNodeMetadata.class);
|
||||
bind(new TypeLiteral<Function<ProductItemPrice, org.jclouds.compute.domain.Image>>() {
|
||||
}).to(ProductItemPriceToImage.class);
|
||||
bind(new TypeLiteral<Function<Set<ProductItemPrice>, org.jclouds.compute.domain.Hardware>>() {
|
||||
}).to(ProductItemPricesToHardware.class);
|
||||
bind(new TypeLiteral<Function<Datacenter, Location>>() {
|
||||
}).to(DatacenterToLocation.class);
|
||||
bind(new TypeLiteral<Supplier<Location>>() {
|
||||
}).to(OnlyLocationOrFirstZone.class);
|
||||
}
|
||||
}
|
|
@ -16,35 +16,49 @@
|
|||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.jclouds.softlayer.functions;
|
||||
package org.jclouds.softlayer.compute.functions;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.jclouds.domain.Location;
|
||||
import org.jclouds.domain.LocationBuilder;
|
||||
import org.jclouds.domain.LocationScope;
|
||||
import org.jclouds.location.suppliers.JustProvider;
|
||||
import org.jclouds.softlayer.domain.Address;
|
||||
import org.jclouds.softlayer.domain.Datacenter;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Iterables;
|
||||
import org.jclouds.domain.Location;
|
||||
import org.jclouds.domain.LocationBuilder;
|
||||
import org.jclouds.domain.LocationScope;
|
||||
import org.jclouds.softlayer.domain.Address;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* Converts an Address into a Location.
|
||||
* Converts an Datacenter into a Location.
|
||||
*/
|
||||
public class AccountToLocation implements Function<Address,Location> {
|
||||
public class DatacenterToLocation implements Function<Datacenter,Location> {
|
||||
private final JustProvider provider;
|
||||
|
||||
// allow us to lazy discover the provider of a resource
|
||||
@Inject
|
||||
public DatacenterToLocation(JustProvider provider) {
|
||||
this.provider = checkNotNull(provider, "provider");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Location apply(Address address) {
|
||||
public Location apply(Datacenter datacenter) {
|
||||
return new LocationBuilder().scope(LocationScope.ZONE)
|
||||
.metadata(ImmutableMap.<String, Object>of())
|
||||
.description(address.getDescription())
|
||||
.id(Long.toString(address.getId()))
|
||||
.iso3166Codes(createIso3166Codes(address))
|
||||
.description(datacenter.getLongName())
|
||||
.id(Long.toString(datacenter.getId()))
|
||||
.iso3166Codes(createIso3166Codes(datacenter.getLocationAddress()))
|
||||
.parent(Iterables.getOnlyElement(provider.get()))
|
||||
.build();
|
||||
}
|
||||
}
|
||||
|
||||
private Iterable<String> createIso3166Codes(Address address) {
|
||||
return ImmutableSet.of(""+address.getCountry()+"-"+address.getState());
|
||||
}
|
||||
private Iterable<String> createIso3166Codes(Address address) {
|
||||
return address != null ? ImmutableSet.<String> of("" + address.getCountry() + "-" + address.getState())
|
||||
: ImmutableSet.<String> of();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,61 @@
|
|||
/**
|
||||
* 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.softlayer.compute.functions;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.inject.Named;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import org.jclouds.compute.domain.Image;
|
||||
import org.jclouds.compute.domain.ImageBuilder;
|
||||
import org.jclouds.compute.reference.ComputeServiceConstants;
|
||||
import org.jclouds.logging.Logger;
|
||||
import org.jclouds.softlayer.domain.ProductItemPrice;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
|
||||
/**
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@Singleton
|
||||
public class ProductItemPriceToImage implements Function<ProductItemPrice, Image> {
|
||||
@Resource
|
||||
@Named(ComputeServiceConstants.COMPUTE_LOGGER)
|
||||
protected Logger logger = Logger.NULL;
|
||||
|
||||
@Override
|
||||
public Image apply(ProductItemPrice from) {
|
||||
|
||||
ImageBuilder builder = new ImageBuilder();
|
||||
//TODO
|
||||
// builder.ids(from.id + "");
|
||||
// builder.name(from.name);
|
||||
// builder.description(from.name);
|
||||
//
|
||||
// OsFamily family = null;
|
||||
// try {
|
||||
// family = OsFamily.fromValue(from.name);
|
||||
// builder.operatingSystem(new OperatingSystem.Builder().name(from.name).family(family).build());
|
||||
// } catch (IllegalArgumentException e) {
|
||||
// logger.debug("<< didn't match os(%s)", from);
|
||||
// }
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,48 @@
|
|||
/**
|
||||
* 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.softlayer.compute.functions;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import org.jclouds.compute.domain.Hardware;
|
||||
import org.jclouds.compute.domain.HardwareBuilder;
|
||||
import org.jclouds.softlayer.domain.ProductItemPrice;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
|
||||
/**
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@Singleton
|
||||
public class ProductItemPricesToHardware implements Function<Set<ProductItemPrice>, Hardware> {
|
||||
|
||||
@Override
|
||||
public Hardware apply(Set<ProductItemPrice> from) {
|
||||
HardwareBuilder builder = new HardwareBuilder();
|
||||
// builder.ids(from.id + "");
|
||||
// builder.name(from.name);
|
||||
// builder.processors(ImmutableList.of(new Processor(from.cores, 1.0)));
|
||||
// builder.ram(from.ram);
|
||||
// builder.volumes(ImmutableList.<Volume> of(new VolumeImpl(from.disk, true, false)));
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,139 @@
|
|||
/**
|
||||
* 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.softlayer.compute.functions;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static org.jclouds.compute.util.ComputeServiceUtils.parseGroupFromName;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import org.jclouds.collect.FindResourceInSet;
|
||||
import org.jclouds.collect.Memoized;
|
||||
import org.jclouds.compute.domain.Hardware;
|
||||
import org.jclouds.compute.domain.Image;
|
||||
import org.jclouds.compute.domain.NodeMetadata;
|
||||
import org.jclouds.compute.domain.NodeMetadataBuilder;
|
||||
import org.jclouds.compute.domain.NodeState;
|
||||
import org.jclouds.domain.Credentials;
|
||||
import org.jclouds.domain.Location;
|
||||
import org.jclouds.softlayer.domain.VirtualGuest;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.base.Supplier;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
/**
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@Singleton
|
||||
public class VirtualGuestToNodeMetadata implements Function<VirtualGuest, NodeMetadata> {
|
||||
|
||||
public static final Map<VirtualGuest.State, NodeState> serverStateToNodeState = ImmutableMap
|
||||
.<VirtualGuest.State, NodeState> builder().put(VirtualGuest.State.RUNNING, NodeState.RUNNING)//
|
||||
.put(VirtualGuest.State.STARTING, NodeState.PENDING)//
|
||||
.put(VirtualGuest.State.DESTROYED, NodeState.TERMINATED)//
|
||||
// TODO other states
|
||||
.put(VirtualGuest.State.UNRECOGNIZED, NodeState.UNRECOGNIZED)//
|
||||
.build();
|
||||
|
||||
private final FindHardwareForVirtualGuest findHardwareForVirtualGuest;
|
||||
private final FindLocationForVirtualGuest findLocationForVirtualGuest;
|
||||
private final FindImageForVirtualGuest findImageForVirtualGuest;
|
||||
private final Map<String, Credentials> credentialStore;
|
||||
|
||||
@Inject
|
||||
VirtualGuestToNodeMetadata(Map<String, Credentials> credentialStore, FindHardwareForVirtualGuest findHardwareForVirtualGuest,
|
||||
FindLocationForVirtualGuest findLocationForVirtualGuest, FindImageForVirtualGuest findImageForVirtualGuest) {
|
||||
this.credentialStore = checkNotNull(credentialStore, "credentialStore");
|
||||
this.findHardwareForVirtualGuest = checkNotNull(findHardwareForVirtualGuest, "findHardwareForVirtualGuest");
|
||||
this.findLocationForVirtualGuest = checkNotNull(findLocationForVirtualGuest, "findLocationForVirtualGuest");
|
||||
this.findImageForVirtualGuest = checkNotNull(findImageForVirtualGuest, "findImageForVirtualGuest");
|
||||
}
|
||||
|
||||
@Override
|
||||
public NodeMetadata apply(VirtualGuest from) {
|
||||
// convert the result object to a jclouds NodeMetadata
|
||||
NodeMetadataBuilder builder = new NodeMetadataBuilder();
|
||||
builder.ids(from.getId() + "");
|
||||
builder.name(from.getNotes());
|
||||
builder.location(findLocationForVirtualGuest.apply(from));
|
||||
builder.group(parseGroupFromName(from.getNotes()));
|
||||
//TODO determine image id (product price)from virtual guest
|
||||
// builder.imageId(from.imageId + "");
|
||||
Image image = findImageForVirtualGuest.apply(from);
|
||||
if (image != null)
|
||||
builder.operatingSystem(image.getOperatingSystem());
|
||||
builder.hardware(findHardwareForVirtualGuest.apply(from));
|
||||
// TODO get state
|
||||
// builder.state(serverStateToNodeState.get(from.getState()));
|
||||
builder.publicAddresses(ImmutableSet.<String> of(from.getPrimaryIpAddress()));
|
||||
builder.privateAddresses(ImmutableSet.<String> of(from.getPrimaryBackendIpAddress()));
|
||||
builder.credentials(credentialStore.get("node#"+ from.getId()));
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
@Singleton
|
||||
public static class FindHardwareForVirtualGuest extends FindResourceInSet<VirtualGuest, Hardware> {
|
||||
|
||||
@Inject
|
||||
public FindHardwareForVirtualGuest(@Memoized Supplier<Set<? extends Hardware>> hardware) {
|
||||
super(hardware);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(VirtualGuest from, Hardware input) {
|
||||
return input.getProviderId().equals(from.getId() + "");
|
||||
}
|
||||
}
|
||||
|
||||
@Singleton
|
||||
public static class FindImageForVirtualGuest extends FindResourceInSet<VirtualGuest, Image> {
|
||||
|
||||
@Inject
|
||||
public FindImageForVirtualGuest(@Memoized Supplier<Set<? extends Image>> hardware) {
|
||||
super(hardware);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(VirtualGuest from, Image input) {
|
||||
// TODO determine the price list from the virtual guest which would have the image in it.
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Singleton
|
||||
public static class FindLocationForVirtualGuest extends FindResourceInSet<VirtualGuest, Location> {
|
||||
|
||||
@Inject
|
||||
public FindLocationForVirtualGuest(@Memoized Supplier<Set<? extends Location>> hardware) {
|
||||
super(hardware);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(VirtualGuest from, Location input) {
|
||||
// TODO determine the price list from the virtual guest which would have the image in it.
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,129 @@
|
|||
/**
|
||||
* 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.softlayer.compute.strategy;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import org.jclouds.compute.ComputeService;
|
||||
import org.jclouds.compute.ComputeServiceAdapter;
|
||||
import org.jclouds.compute.domain.Template;
|
||||
import org.jclouds.domain.Credentials;
|
||||
import org.jclouds.softlayer.SoftLayerClient;
|
||||
import org.jclouds.softlayer.domain.Datacenter;
|
||||
import org.jclouds.softlayer.domain.ProductItemPrice;
|
||||
import org.jclouds.softlayer.domain.ProductPackage;
|
||||
import org.jclouds.softlayer.domain.VirtualGuest;
|
||||
import org.jclouds.softlayer.predicates.ProductPackagePredicates;
|
||||
import org.jclouds.softlayer.reference.SoftLayerConstants;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Iterables;
|
||||
|
||||
/**
|
||||
* defines the connection between the {@link SoftLayerClient} implementation and the jclouds
|
||||
* {@link ComputeService}
|
||||
*
|
||||
*/
|
||||
@Singleton
|
||||
public class SoftLayerComputeServiceAdapter implements
|
||||
ComputeServiceAdapter<VirtualGuest, Set<ProductItemPrice>, ProductItemPrice, Datacenter> {
|
||||
private final SoftLayerClient client;
|
||||
private final String virtualGuestPackageName;
|
||||
|
||||
@Inject
|
||||
public SoftLayerComputeServiceAdapter(SoftLayerClient client,
|
||||
@Named(SoftLayerConstants.PROPERTY_SOFTLAYER_VIRTUALGUEST_PACKAGE_NAME) String virtualGuestPackageName) {
|
||||
this.client = checkNotNull(client, "client");
|
||||
this.virtualGuestPackageName = checkNotNull(virtualGuestPackageName, "virtualGuestPackageName");
|
||||
}
|
||||
|
||||
@Override
|
||||
public VirtualGuest createNodeWithGroupEncodedIntoNameThenStoreCredentials(String tag, String name,
|
||||
Template template, Map<String, Credentials> credentialStore) {
|
||||
VirtualGuest from = null; // TODO create the backend object using parameters from the
|
||||
// template. ex.
|
||||
// VirtualGuest from =
|
||||
// client.getVirtualGuestClient().createServerInDC(template.getLocation().getId(), name,
|
||||
// Long.parseLong(template.getImage().getProviderId()),
|
||||
// Long.parseLong(template.getHardware().getProviderId()));
|
||||
// store the credentials so that later functions can use them
|
||||
// credentialStore.put("node#"+ from.getId() + "", new Credentials(from.loginUser,
|
||||
// from.password));
|
||||
return from;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<Set<ProductItemPrice>> listHardwareProfiles() {
|
||||
// TODO: get the set of product item prices corresponding to the hardware profiles
|
||||
return ImmutableSet.of();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<ProductItemPrice> listImages() {
|
||||
// TODO: get the list of product item prices corresponding to images
|
||||
return ImmutableSet.of();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<VirtualGuest> listNodes() {
|
||||
return client.getVirtualGuestClient().listVirtualGuests();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<Datacenter> listLocations() {
|
||||
// TODO we should be able to specify a filter that gets the datacenters here.
|
||||
ProductPackage virtualGuestPackage = Iterables.find(client.getAccountClient().getActivePackages(),
|
||||
ProductPackagePredicates.named(virtualGuestPackageName));
|
||||
return client.getProductPackageClient().getProductPackage(virtualGuestPackage.getId()).getDatacenters();
|
||||
}
|
||||
|
||||
@Override
|
||||
public VirtualGuest getNode(String id) {
|
||||
long serverId = Long.parseLong(id);
|
||||
return client.getVirtualGuestClient().getVirtualGuest(serverId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroyNode(String id) {
|
||||
// TODO
|
||||
// client.getVirtualGuestClient().destroyVirtualGuest(Long.parseLong(id));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void rebootNode(String id) {
|
||||
client.getVirtualGuestClient().rebootHardVirtualGuest(Long.parseLong(id));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resumeNode(String id) {
|
||||
client.getVirtualGuestClient().resumeVirtualGuest(Long.parseLong(id));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void suspendNode(String id) {
|
||||
client.getVirtualGuestClient().pauseVirtualGuest(Long.parseLong(id));
|
||||
}
|
||||
}
|
|
@ -22,7 +22,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
|||
|
||||
import java.util.Set;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import org.jclouds.javax.annotation.Nullable;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Sets;
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
*/
|
||||
package org.jclouds.softlayer.domain;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import org.jclouds.javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* The SoftLayer_Product_Item_Price data type contains general information
|
||||
|
|
|
@ -18,33 +18,18 @@
|
|||
*/
|
||||
package org.jclouds.softlayer.predicates;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
import org.jclouds.softlayer.domain.ProductPackage;
|
||||
import org.jclouds.softlayer.features.AccountClient;
|
||||
|
||||
import java.util.NoSuchElementException;
|
||||
import com.google.common.base.Predicate;
|
||||
|
||||
public class ProductPackagePredicates {
|
||||
|
||||
/**
|
||||
* Attempts to obtain the packageId for the supplied packageName.
|
||||
* @param accountClient @see AccountClient
|
||||
* @param packageName The name field of the @see ProductPackage to find
|
||||
* @return The id of the package or null if no match found
|
||||
*/
|
||||
public static Long getProductPackageId(AccountClient accountClient,String packageName) {
|
||||
for (ProductPackage productPackage : accountClient.getActivePackages()) {
|
||||
if (named(packageName).apply(productPackage)) return productPackage.getId();
|
||||
}
|
||||
throw new NoSuchElementException("ProductPackage:"+packageName+" not found");
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests if the product package name equals the packageName
|
||||
* @param packageName
|
||||
* @return true if the name is equal, otherwise false.
|
||||
*/
|
||||
public static Predicate named(final String packageName) {
|
||||
public static Predicate<ProductPackage> named(final String packageName) {
|
||||
return new Predicate<ProductPackage>() {
|
||||
public boolean apply(ProductPackage productPackage) {
|
||||
return productPackage.getName().equals(packageName);
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
/**
|
||||
* 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.softlayer.reference;
|
||||
|
||||
/**
|
||||
* Configuration properties and constants used in SoftLayer connections.
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public interface SoftLayerConstants {
|
||||
/**
|
||||
* Name of the product package corresponding to cloud servers
|
||||
*/
|
||||
public static final String PROPERTY_SOFTLAYER_VIRTUALGUEST_PACKAGE_NAME = "jclouds.softlayer.virtualguest.package-name";
|
||||
|
||||
}
|
|
@ -0,0 +1,72 @@
|
|||
/**
|
||||
* 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.softlayer.compute;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
|
||||
import org.jclouds.compute.ComputeServiceContext;
|
||||
import org.jclouds.compute.ComputeServiceContextFactory;
|
||||
import org.jclouds.logging.log4j.config.Log4JLoggingModule;
|
||||
import org.jclouds.sshj.config.SshjSshClientModule;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.inject.Module;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@Test(groups = "live", testName = "SoftLayerExperimentLiveTest")
|
||||
public class SoftLayerExperimentLiveTest {
|
||||
protected String provider = "softlayer";
|
||||
protected String identity;
|
||||
protected String credential;
|
||||
protected String endpoint;
|
||||
protected String apiversion;
|
||||
|
||||
@BeforeClass
|
||||
protected void setupCredentials() {
|
||||
identity = checkNotNull(System.getProperty("test." + provider + ".identity"), "test." + provider + ".identity");
|
||||
credential = System.getProperty("test." + provider + ".credential");
|
||||
endpoint = System.getProperty("test." + provider + ".endpoint");
|
||||
apiversion = System.getProperty("test." + provider + ".apiversion");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAndExperiment() {
|
||||
ComputeServiceContext context = null;
|
||||
try {
|
||||
String identity = checkNotNull(System.getProperty("test.softlayer.identity"), "test.softlayer.identity");
|
||||
String credential = checkNotNull(System.getProperty("test.softlayer.credential"), "test.softlayer.credential");
|
||||
|
||||
context = new ComputeServiceContextFactory().createContext("softlayer", identity, credential, ImmutableSet
|
||||
.<Module> of(new Log4JLoggingModule(), new SshjSshClientModule()));
|
||||
|
||||
assertEquals(context.getComputeService().listAssignableLocations().size(), 5);
|
||||
|
||||
} finally {
|
||||
if (context != null)
|
||||
context.close();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -16,56 +16,58 @@
|
|||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.jclouds.softlayer.functions;
|
||||
|
||||
import org.jclouds.domain.Location;
|
||||
import org.jclouds.softlayer.domain.Address;
|
||||
import org.testng.annotations.BeforeMethod;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import java.util.Set;
|
||||
package org.jclouds.softlayer.compute.functions;
|
||||
|
||||
import static org.testng.AssertJUnit.assertEquals;
|
||||
import static org.testng.AssertJUnit.assertTrue;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.Set;
|
||||
|
||||
import org.jclouds.domain.Location;
|
||||
import org.jclouds.location.suppliers.JustProvider;
|
||||
import org.jclouds.softlayer.domain.Address;
|
||||
import org.jclouds.softlayer.domain.Datacenter;
|
||||
import org.testng.annotations.BeforeMethod;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
/**
|
||||
* Tests {@code AddressToLocation}
|
||||
* Tests {@code DatacenterToLocation}
|
||||
*
|
||||
* @author Jason King
|
||||
*/
|
||||
@Test(sequential = true,groups = "unit")
|
||||
public class AddressToLocationTest {
|
||||
@Test(singleThreaded = true, groups = "unit")
|
||||
public class DatacenterToLocationTest {
|
||||
|
||||
private AccountToLocation function;
|
||||
private DatacenterToLocation function;
|
||||
|
||||
@BeforeMethod
|
||||
public void setup() {
|
||||
function = new AccountToLocation();
|
||||
function = new DatacenterToLocation(new JustProvider(ImmutableSet.<String>of(), "softlayer", URI.create("foo")));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAddressToLocation() {
|
||||
Address address = Address.builder().id(1)
|
||||
.country("US")
|
||||
.state("TX")
|
||||
.description("This is Texas!").build();
|
||||
public void testDatacenterToLocation() {
|
||||
Datacenter address = Datacenter.builder().id(1).longName("This is Texas!").locationAddress(
|
||||
Address.builder().country("US").state("TX").description("This is Texas!").build()).build();
|
||||
|
||||
Location location = function.apply(address);
|
||||
|
||||
assertEquals(location.getId(), Long.toString(address.getId()));
|
||||
Set<String> iso3166Codes = location.getIso3166Codes();
|
||||
assertEquals(iso3166Codes.size(),1);
|
||||
assertEquals(iso3166Codes.size(), 1);
|
||||
assertTrue(iso3166Codes.contains("US-TX"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetIso3166CodeNoCountryAndState() {
|
||||
Address address = Address.builder().id(1)
|
||||
.description("Nowhere").build();
|
||||
Datacenter address = Datacenter.builder().id(1).longName("Nowhere").build();
|
||||
Location location = function.apply(address);
|
||||
|
||||
assertEquals(location.getId(), Long.toString(address.getId()));
|
||||
Set<String> iso3166Codes = location.getIso3166Codes();
|
||||
assertEquals(iso3166Codes.size(),1);
|
||||
assertTrue(iso3166Codes.contains("null-null"));
|
||||
assertEquals(iso3166Codes.size(), 0);
|
||||
}
|
||||
}
|
|
@ -20,15 +20,11 @@ package org.jclouds.softlayer.features;
|
|||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
import org.jclouds.compute.ComputeServiceContextFactory;
|
||||
import org.jclouds.logging.log4j.config.Log4JLoggingModule;
|
||||
import org.jclouds.rest.RestContext;
|
||||
import org.jclouds.rest.RestContextFactory;
|
||||
import org.jclouds.softlayer.SoftLayerAsyncClient;
|
||||
import org.jclouds.softlayer.SoftLayerClient;
|
||||
import org.jclouds.softlayer.SoftLayerContextBuilder;
|
||||
import org.jclouds.softlayer.SoftLayerPropertiesBuilder;
|
||||
import org.testng.annotations.AfterGroups;
|
||||
import org.testng.annotations.BeforeGroups;
|
||||
import org.testng.annotations.Test;
|
||||
|
@ -51,12 +47,9 @@ public class BaseSoftLayerClientLiveTest {
|
|||
String identity = checkNotNull(System.getProperty("test.softlayer.identity"), "test.softlayer.identity");
|
||||
String credential = checkNotNull(System.getProperty("test.softlayer.credential"), "test.softlayer.credential");
|
||||
|
||||
Properties restProperties = new Properties();
|
||||
restProperties.setProperty("softlayer.contextbuilder", SoftLayerContextBuilder.class.getName());
|
||||
restProperties.setProperty("softlayer.propertiesbuilder", SoftLayerPropertiesBuilder.class.getName());
|
||||
|
||||
context = new RestContextFactory(restProperties).createContext("softlayer", identity, credential,
|
||||
ImmutableSet.<Module> of(new Log4JLoggingModule()));
|
||||
context = new ComputeServiceContextFactory().createContext("softlayer", identity, credential,
|
||||
ImmutableSet.<Module> of(new Log4JLoggingModule())).getProviderSpecificContext();
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -19,6 +19,8 @@
|
|||
package org.jclouds.softlayer.features;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Iterables;
|
||||
|
||||
import org.jclouds.softlayer.domain.*;
|
||||
import org.jclouds.softlayer.predicates.ProductPackagePredicates;
|
||||
import org.testng.annotations.BeforeGroups;
|
||||
|
@ -83,8 +85,10 @@ public class ProductPackageClientLiveTest extends BaseSoftLayerClientLiveTest {
|
|||
|
||||
Set<Datacenter> expected = builder.build();
|
||||
|
||||
Long productPackageId = ProductPackagePredicates.getProductPackageId(accountClient, CLOUD_SERVER_PACKAGE_NAME);
|
||||
assertNotNull(productPackageId);
|
||||
// note we don't need to check null, as this will throw NoSuchElementException if
|
||||
// a product package named as below isn't found.
|
||||
long productPackageId = Iterables.find(accountClient.getActivePackages(),
|
||||
ProductPackagePredicates.named(CLOUD_SERVER_PACKAGE_NAME)).getId();
|
||||
|
||||
ProductPackage productPackage = client.getProductPackage(productPackageId);
|
||||
Set<Datacenter> datacenters = productPackage.getDatacenters();
|
||||
|
|
Loading…
Reference in New Issue